Jump to content

Passing variables from one page to the next


oracle259

Recommended Posts

Use sessions.
You must have [code]session_start();[/code] at the top of the page you want to define or call sessions or you will get some nice errors...

Then, simply register assign your session to a variable. Eg :
[code]
<?
session_start();
$name="Olly";

session_register('name');
$_SESSION['name'] = $name;
?>
[/code]

Then you can use the value assigned to $name on any page by calling [code]$_SESSION('name');[/code] eg,

[code]
<?
session_start();

echo "Name:" . $_SESSION['name'];

// Prints:
// Name: Olly
?>
[/code]
Link to comment
Share on other sites

lowe_22:

I just recently discovered, dont recommend register_session() as this function wont be supported on systems without register_globals, and in version 6, wont be supported at all.

Instead recommend:

<?

session_start();
$name="Olly";
$_SESSION['name'] = $name;

?>
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.