...

View Full Version : passing variables values using POST



sudhakararaog
03-17-2008, 02:13 AM
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.

rafiki
03-17-2008, 02:17 AM
$_SESSION['firstname']
Google Search php sessions

sudhakararaog
03-18-2008, 01:39 AM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum