Page 1 of 1

Mixed up data from $_GET [SOLVED]

Posted: Sun Sep 16, 2007 1:11 pm
by enchance
My data is getting mixed up when I fetch it 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:

Code: Select all

<?php
//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
}
?>
But this is what came out in "sent.php"

Code: Select all

//The appended URL suddenly became: http://www.mydomain.com/sent.php?sendername=John%2520Doe
  $name = $_GET['sendername'];
  echo $name //Prints out "John%20Doe" instead of "John Doe"
I wonder what happened...

Re: Mixed up data from $_GET

Posted: Sun Sep 16, 2007 1:35 pm
by superdezign
enchance wrote:

Code: Select all

//The appended URL suddenly became: http://www.mydomain.com/sent.php?sendername=John%2520Doe
  $name = $_GET['sendername'];
  echo $name //Prints out "John%20Doe" instead of "John Doe"
It is url-encoding the url-encoded data, changing "John%20Doe" into "John%2520Doe." Do you use urlencode() or urldecode() in in your code?

Posted: Sun Sep 16, 2007 2:14 pm
by enchance
I got it to work using rawurldecode(). Thanks a lot for replying!