Jump to content

i have problem with header function


ms_dos10

Recommended Posts

Hi i have problem with header function , i want send or pass variable from one page to another page with help of header function .frist page :

					$mymsg = 'Unon User Name & Password Plz Try Again <br>';					header("Location: http://index.php?msg=$mymsg");

second page here i want pass my variable :i'll get it like that or what 'couse its not working with me here .

<?phpif(isset($_GET['$msg'])){echo "Wrong :" . $_GET['$msg'];		}?>

Link to comment
Share on other sites

Two things appear to be happening here:

  1. The value of "msg" will always be "$mymsg" rather than the value that is assigned to your $mymsg variable.
  2. You would most likely run into problems with the spaces, ampresand (&) and angle brakets in the value. It needs to be url encoded.

I'm not a PHP developer, so forgive me any errors, but something like this should fix it:

$mymsg = 'Unon User Name & Password Plz Try Again <br>';header("Location: http://index.php?msg=".urlencode($mymsg));

Of course, you'll also need to decode the string once you get to the second page:

$mymsg = urldecode($_GET['$msg']);

Link to comment
Share on other sites

just a question to Jesh: what are angle brackets? Are you talking about the less than (<) and great than (>) symbols? Cause thats what they are called by the people who design web programming languages (like the code to display an < is <)

Link to comment
Share on other sites

just a question to Jesh: what are angle brackets? Are you talking about the less than (<) and great than (>) symbols? Cause thats what they are called by the people who design web programming languages (like the code to display an < is <)
Yeah, I call the "less than" (<) and "greater than" (>) symbols "angle brackets".
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...