Starting a PHP Session
After clicking on the button Check, the page start.html in the folder session will call the script 1.php.
In 1.php, you must first start up the session before you can store user information in your PHP session.
The session_start function must appear before the <html> tag.
|
|
|
|
|
|
|
|
<?php
unset( $_SESSION['customer'] );
session_start( );
$_SESSION['customer'] = $_POST['name'];
?>
<html><body>
<?php
echo "Page 1";
echo "Name = " . $_SESSION['customer'];
echo "<form method='post' action='2.php'>
<input type='submit' name='act'
value='Check' /></form>";
?>
</body></html>
|
|