Jump to content

Passing variables between pages


AdRock

Recommended Posts

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?

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.