By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

passing hidden values

P: 54
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 "<input type ='hidden' name='duplicateuser' value='$username'>";
echo "<input type ='hidden' name='fname' value='$fname'>";

please advice.

thanks.
Feb 23 '08 #1
Share this Question
Share on Google+
1 Reply


P: 61
You said you had got an error but you did not mentioned what error it is?
if you want the post method you should submit the form using
javascript. then you would get the values in the processing page.

otherwise you could also do it simply like this. I am not a pro but i feel comfortable in doing this way.

Instead of redirecting to another page you could have submitted the form to the same page so that you wont' need to pass the values to another page. if the user is already available you could allow the option of doing the registration once more by using the same form. If successfully registered you can show the "registration successful message and avoid the rest of the form (don't show the form).
Feb 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.