# passing hidden values in php



## sudhakararaog (Sep 6, 2007)

i have an if else situation wherein if a user registers with a name that is already available in the database i redirect them to duplicateuser.php or else redirect to thankyou.php

presently i am able to pass value of a variable $username as part of the url and i am able to read using GET by doing so the value appears in the browser address bar and i would like to use hidden and also be able to read this value

following is the code i am presently using

if($usernamerows > 0)
{ 
header("Location: duplicateuser.php?duplicateuser=".$username); 
}
else
{
header("Location: thankyou.php?fname=".$fname); 
}

how can i use hidden so that the url does not get appended in the address bar and still the read the value of the variables i want to pass and how should i read the variables in the other pages, is it $_POST[]

i tried using this code just before the header() statement but it does not work and i get an error.

echo "";
echo "";

please advice.

thanks.


----------



## MMJ (Oct 15, 2006)

Why do you want to remove it from the url?

You can send it in the session, if you want.


----------



## treydx (Jan 4, 2006)

If you just don't want it to show up in the address bar, you need to change the method attribute in your form tag to POST instead of GET. Then you can read that variable from your php pages using $_POST.

You don't need the tags unless you want to send extra variables that the user will not enter into a form. When you echo those hidden tags into a page, the user will have to submit another form from that page to get to those values of the hidden form elements.


----------



## DrP (Jul 23, 2005)

Session variables would be a good bet, as you won't need to keep sending them in a form. Here's a link you could look at:

http://www.smallbizonline.co.uk/php_session_variables.php


----------

