passing hidden values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • runway27
    Banned
    New Member
    • Sep 2007
    • 54

    passing hidden values

    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.p hp 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($usernamerow s > 0)
    {
    header("Locatio n: duplicateuser.p hp?duplicateuse r=".$username );
    }
    else
    {
    header("Locatio n: thankyou.php?fn ame=".$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='duplicate user' value='$usernam e'>";
    echo "<input type ='hidden' name='fname' value='$fname'> ";

    please advice.

    thanks.
  • samatair
    New Member
    • Nov 2007
    • 61

    #2
    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 "registrati on successful message and avoid the rest of the form (don't show the form).

    Comment

    Working...