www.webdeveloper.com
Results 1 to 8 of 8

Thread: How to send a value to another php page?

  1. #1
    Join Date
    Apr 2005
    Posts
    210

    Question How to send a value to another php page?

    Page 1:

    <?php
    $uid=$_GET['uid'];
    header("location: ...../page2.php");
    die();
    ?>

    how to get value of $uid in page2.php?

    Note:

    I don't want to use
    ..../page2.php?uid=$uid
    this is why I redirect page 1 to page 2.
    I hope uid is hidden from user on web address box.

    Thanks
    Last edited by html20009876; 08-05-2009 at 12:46 AM.

  2. #2
    Join Date
    Aug 2009
    Posts
    30
    the only way to hide transmitted vars from the URL is to send them via post instead of get.

    HTML Code:
    <form action="page1.php" method="post">
        <input type="text" name="uid"/>
    </form>
    calling the var in php would then work via the post var

    Code:
     $uid=$_GET['uid'];
    but why dont you want to use the get thing?
    if u just use the page1 to redirect it will never be displayed in the browsers address box


    cu
    huckepick

  3. #3
    Join Date
    Apr 2005
    Posts
    210
    "post" and _GET[]?
    boy, before you become a teacher, you should complete your 12 years study first.

  4. #4
    Join Date
    Aug 2009
    Posts
    30
    I am sorry for mistyping that

    i just copied an forgot to change
    Code:
    $uid=$_POST['uid'];
    i just wanted to help
    and consider your reaction on this little mistake as quite unfriendly

    cu
    huckepick

  5. #5
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    Come on guys, what about sessions?

    simply start the session using the function session_start() and then set your session like

    $_SESSION['uid']=$id;

    for example ......page 1:

    PHP Code:
    <?php
    $uid
    =$_GET['uid'];
    session_start();
    $_SESSION['uid']=$uid;
    header("Location: ...../page2.php");
    ?>
    Page 2:

    PHP Code:
    <?PHP

    session_start
    ();
    $uid=$_SESSION['uid'];

    ?>
    Obviously, i recommend validating the first GET before using any of this, and also validate all session values before using them, never know what your user might of done to them.

    Ryan

  6. #6
    Join Date
    Aug 2009
    Posts
    30
    i just focused on the transmitting part of the problem and forgot about handling the data at all

    definitely as session would be the way to store $uid before redirecting.

    cu
    huckepick

  7. #7
    Join Date
    Mar 2009
    Location
    Yorkshire
    Posts
    266
    Yeah definatly, i just thought i would drop the validation stuff in there just incase you had just started out at PHP, or even programming for that matter. As long as you have it all in control =)

    Ryan

  8. #8
    Join Date
    Nov 2008
    Posts
    2,477
    Quote Originally Posted by html20009876 View Post
    "post" and _GET[]?
    boy, before you become a teacher, you should complete your 12 years study first.
    Nice response, remind me to never bother posting anything helpful in one of your threads... It's pretty funny that you don't know enough to answer this for yourself, yet you are happy to mock people who do know more and are trying to help you out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles