mixed up getting data from $_GET

Discussion in 'PHP' started by enchance, Sep 16, 2007.

  1. #1
    My data is getting mixed up when I get my data from GET. This is what I have:
    1. "contact.php" contains the form. All form data is then passed to "mail.php" using POST
    2. "mail.php" fixes the data then runs a simple test. If the email was successful it sends $sendername to "sent.php" using GET
    3. "sent.php" recieves the file then prints $sendername out in a simple message like "Thank you $sendername" or something. View code below:

    
    <?
    //Inside "mail.php" which sends $sendername using GET after recieving it using POST
    if(mail($agiemail, $subject, $message, $header))
    {
    	$sendername = $_POST['fName']; //fName is "John Doe" for example
    	header("Location: http://mydomain.com/sent.php?sendername=$sendername ");
    }
    else
    {
    	//sent to an error message
    }
    ?>
    
    Code (markup):
    But this is what came out in "sent.php"
    
    <?
    //The appended URL was: http://www.mydomain.com/sent.php?sendername=John%2520Doe
      $name = $_GET['sendername'];
      echo $name //Prints out "John%20Doe" instead of "John Doe"
    ?>
    
    Code (markup):
    I know I made a simple mistake somewhere...:confused:
     
    enchance, Sep 16, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Sep 16, 2007 IP
  3. enchance

    enchance Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot! That worked just fine!
     
    enchance, Sep 16, 2007 IP