Can any one help me about how to get get the value of variables in the url bar so that i acess them using $_GET method Was trying to give a header aswell send the variables through url and acess them but it didnot help me. Not getting it right How do you specify the header. What i tried was header("location:xyz.php?mess=".$message); But nor the header works neither the $message passes through url
header("Location: xyz.php?mess=".$message); actually should work ; are you sure it doesn't? test1.php: <? $message="test"; header("Location: test2.php?mess=".$message); exit; ?> test2.php: <? print_r($_GET); ?> gives me ; Array ( [mess] => test ) Or am I not getting what you mean? If you really want it in your address bar (to have it appear there); function _redirect($link) { echo '<META HTTP-EQUIV="Refresh" CONTENT="0; URL='.$link.'">'; } _redirect("http://www.bla.com/xyz.php?mess=".$message); exit;
I as getting an error as cannot send header information. I was trying usin to validate a form with if & else if($name==""){ $message="please enter your name"; header("Location: test2.php?mess=".$message); } else{ if($address==""){ $message1="please enter your address"; header("Location: test2.php?mess=".$message1); else{ echo "thankyou"; } } Is that exit; what you use needed?
Ya i ment th same thing. specified the $message="please enter your name"; $message1="please enter your address";
You need to send header information before sending ANYTHING else, and it is very good practice to ALWAYS(!!!) put exit; after a header("Location: because you might create very serious security problems if you don't. Most commercial and open source software have had security leaks because of this, most notably some well known hosting admin panels which allowed none authenticated users to log-in because the script was executed after header("Location: . An example (offtopic, though users might find it useful): <? if(!logged_on()) { header("Location: login.php"); } do_something_only_a_logged_on_user_may_do(); ?>