SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok here is what I am TRYING to do.

    I am trying to develop a simple affiliate system.

    This is what I have right now for the "Add Affiliate" page. The problem is not here really, it's in the cookie setting code.

    I understand that cookies are apparently really dumb and hard to use, and this seems to be very true since I can't figure them out. So...the add.php3 creates a new file that SHOULD set a cookie and then redirect the person to the home page. At the home page the persons name should come up as the refer, however I don't believe the cookie is being stored at all. And it most definately is NOT working.

    The Add part is here:

    http://www.imhosting.com/r/add.php3

    And this is the code to that file:
    Code:
    <html>
    <head>
    <title>Add Me</title>
    </head>
    
    <body bgcolor="#FFFFFF">
    
    <?
    
    if($id) {
    	if(!is_file("$id.php3")) {
    		$file = fopen("$id.php3","w");
    		$html = "<? SetCookie('wchReferer','$id','time()+829304','../','www.imhosting.com'); header('Location: http://www.imhosting.com/index.php3'); ?>"; 
    		fputs($file, "$html");
    		echo(" User added. \n\n <a href='http://www.imhosting.com/r/$id.php3'>http://www.imhosting.com/r/$id.php3</a> ");
    	} else {
    ?>
    
    <br> User name taken. Please try another. Thank you. <br>
    <br>
    <form action=add.php3 method=post>
      User ID 
      <input type="text" name="id">
      <input type="submit" value="Add Me">
    </form>
    
    
    <?
    	}
    } else {
    ?>
    
    <form action=add.php3 method=post>
      User ID 
      <input type="text" name="id">
      <input type="submit" value="Add Me">
    </form>
    
    
    <?
    }
    
    ?>
    </body>
    </html>

    Thanks Mucho.
    -Mil

  2. #2
    SitePoint Wizard westmich's Avatar
    Join Date
    Mar 2000
    Location
    Muskegon, MI
    Posts
    2,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may want to edit the title of your post. You misspelled stupid. I will not point out the irony of that
    Westmich
    Smart Web Solutions for Smart Clients
    http://www.mindscapecreative.com

  3. #3
    Non-Member
    Join Date
    Apr 2000
    Location
    Waco, Texas.
    Posts
    188
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cookies cannot be set unless they are sent before any other headers (ie- "<html><body>....")

    Instead, try placing it before all of your html.
    Secondly, I am not quite sure what your trying to attempt with:
    Code:
    $file = fopen("$id.php3","w");
    $html = "<? SetCookie('wchReferer','$id','time()+829304','../','www.imhosting.com'); header('Location: http://www.imhosting.com/index.php3'); ?>";
    fputs($file, "$html");
    So set the cookie, simply use
    Code:
    <?
    SetCookie('wchReferer','$id','time()+829304','../','www.imhosting.com'); 
    ?>
    Hope that helps.

  4. #4
    You want what? By when?? Milamber's Avatar
    Join Date
    Jan 2001
    Location
    California
    Posts
    342
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code creates a file in the r/ directory. This file is supposed to set a cookie identifying the person who got the click through, and then redirect the people to our site.

    I am not trying to set a cookie while in the add.php3, instead in the file created you would get this:

    Code:
     
    <? SetCookie("wchReferer","$id","time()+829304","../","www.imhosting.com"); header("Location: http://www.imhosting.com/index.php3"); ?>


    And yes, I know i spelled stoopid wrong. :-)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •