AdRock Posted March 8, 2008 Share Posted March 8, 2008 I have a registration form which takes some POST variables and validates user input which works fine (apart from some of the regex). I would like these variables passed from the registration form to another page which is the registration success page but I can't get the variables to pass between pages. I have used global before the variable names but it still doesn't work These are some of the variables i want to pass //set up some global variables to be passed between validation function and form global $_POST, $error, $print_again, $register, $message; global $first_name, $last_name; global $houseno, $street, $town, $county, $postcode, $telephone; global $email1, $email2, $username, $password1, $password2; //variables for checking the user's name $first_name = $_POST['first_name']; $last_name = $_POST['last_name']; //variable for checking the user address and telephone $houseno = $_POST['houseno']; $street = $_POST['street']; $town = $_POST['town']; $county = $_POST['county']; this is a cut down version of the page i want the varaibles passed to <?php global $first_name; echo "<h1>".$first_name."</h1>"; ?> Is there a simple way of passing these variables or have i got to create a session to do it? Quote Link to comment Share on other sites More sharing options...
balistic Posted March 8, 2008 Share Posted March 8, 2008 create a session, unless you want the url to contain the variables contents which isnt so nice Quote Link to comment Share on other sites More sharing options...
ohdang888 Posted March 8, 2008 Share Posted March 8, 2008 EDIT: beaten to it 2 ways i know of.... 1: log the user in. and in the session, store the id of the user. then on the next page, grab that info from the session, and use a query to draw that info... this is probably the easiest way... do you know how to store info in sessions? this is probably the most secure too. OR 2: well after the account was created... do this.. echo "<meta http-equiv='refresh' content='0;url=success.php?id=<?php echo $id ?>'>"; then on the success.php page, use this code... <?php function sql_quote($data) { if (get_magic_quotes_gpc()) { $data = stripslashes($data); } return addslashes($data); } $id= sql_quote($_GET['id']); and query to get that info for this id. Quote Link to comment Share on other sites More sharing options...
AdRock Posted March 8, 2008 Author Share Posted March 8, 2008 I did think that I had to create a session but i was hoping for a simple way but thinking about it, that is simple enough. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.