#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Copenhagen, Denmark
    Posts
    3
    Rep Power
    0
    I have this problem: First I have a login/password page, with a checkbox.

    If the checkbox is checked I want to be redirected to i.e pagetwo.php with the $login and $password variables.

    else redirect to pagethree.php with $login $password variables

    As far as I can understand is it NOT possible to redirect to a page with variables tagging along, or am I wrong?

    Erik

    ------------------
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    15
    No, it is possible, but security reasons may dictate which way you go ...

    You would want to encrypt the password in the query string if you were using Location. Redirection is done using the header() function:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?
    header("Location: <A HREF="http://www.yourdomain.com/page2.php?l=$login&p=$encrypted_pass");" TARGET=_blank>http://www.yourdomain.com/page2.php?l=$login&p=$encrypted_pass");</A>
    ?>
    [/code]

    The problem with the code above is that isn't really that secure at all, especially since it shows the information in the url location window to see. If the surfer gave out the url anyone could easily get to page two. Is there a better way? Yup. Cookies:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?
    // if the login and pass is correct set a cookie for this browser session only
    setcookie("login, $login");
    setcookie("pass, $password");
    header("Location: <A HREF="http://www.yourdomain.com/page2.php");" TARGET=_blank>http://www.yourdomain.com/page2.php");</A>
    ?>
    [/code]

    Now you can check on page two and see if the person actually has the right login and pass cookie in their browser and let them in or redirect them back using a rubber band like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?
    if($HTTP_REFERER != "") {
    header("Location: $HTTP_REFERER");
    } else {
    header("Location: <A HREF="http://www.yourdomain.com/yourpage.html");" TARGET=_blank>http://www.yourdomain.com/yourpage.html");</A> // it is a bookmarker or type-in so redirect somewhere valid
    }
    ?>
    [/code]

    There are other techniques one can use to accomplish this like sending through a gate page and then to the content page or using sessions in addition to the login to create state, but these things are more involved than space allows me to get into here. And probably I've already given you a lot more information than you asked for hehe

    Hope this helps
    ------------------
    <UL TYPE=SQUARE>
    <LI> TD Scripts
    <LI> Script School
    <LI>php-scripts
    </UL>

    [This message has been edited by TDavid (edited August 29, 2000).]

Similar Threads

  1. Passing POST variables
    By rlorenzo in forum PHP Development
    Replies: 11
    Last Post: June 6th, 2004, 02:00 PM
  2. Replies: 2
    Last Post: February 10th, 2004, 11:03 PM
  3. It won't write the variables into the database!
    By coverman in forum PHP Development
    Replies: 2
    Last Post: January 1st, 2004, 12:41 PM
  4. jsp forward vs redirect +patterns
    By bculp2000 in forum Java Help
    Replies: 1
    Last Post: December 27th, 2003, 11:49 AM
  5. form redirect (keeping variables)
    By adiwillow in forum PHP Development
    Replies: 1
    Last Post: December 11th, 2003, 11:26 AM

IMN logo majestic logo threadwatch logo seochat tools logo