Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    passing variables values using POST

    i am presently passing the value of a variable to a php file using GET after data has been inserted to the database.

    ex=

    $firstname = $_POST["firstname"];

    if(!$sqlconnection)
    {
    echo "error message";
    }
    else
    {
    header("Location: thankyou.php?firstnameis=$firstname");
    }

    how can i send the value of $firstname using POST instead of GET as the value is presently appearing in the address bar. ideally i would like using POST.

    NOTE = please suggest techniques that does NOT involve javascript in order to pass $firstname using POST method, as i have done the entire validations using php and i have assumed that user has javascript turned off.

    please advice.

    thanks.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,046
    Thanks
    19
    Thanked 42 Times in 42 Posts
    $_SESSION['firstname']
    Google Search php sessions

  • #3
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts
    thanks for letting me know. i have used session and it works without adding the variable name and value in the url.

    just wanted to confirm what i am doing is correct. i have 2 files a) form.php which gathers information entered in the form and b) thankyou.php which extracts the value of firstname store in form.php as $fname and displays this $fname and a thankyou message.

    code in form.php
    ==============================================================================
    session_start(); // AS THE VERY FIRST LINE FOLLOWED BY
    session_register("firstnameis");

    $fname = $_POST["fname"];
    $_SESSION['firstnameis'] = $fname; // SOMEWHERE IN BETWEEN THE CODE
    ==============================================================================

    code in thankyou.php
    ==============================================================================
    session_start(); // AS THE VERY FIRST LINE

    Dear <?php echo $_SESSION['firstnameis']; ?> thank you for registering etc...
    ==============================================================================

    1. do i need to destroy or unregister the session variable in thankyou.php and if so can i write that unregister statement after displaying <?php echo $_SESSION['firstnameis']; ?>


    please advice.

    thanks.


  •  

    Posting Permissions

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