/*create_session.php*/ <?php if($_SERVER[‘REQUEST_METHOD‘]==‘POST‘) { if($_POST[‘email‘]) { $a=$_POST[‘email‘]; $b=$_POST[‘password‘]; session_start(); $_SESSION[‘email‘]=$a; $_SESSION[‘password‘]=$b; header(‘location:view_session.php‘); exi
/*view.php*/ <?php session_start(); print "email address:".$_SESSION[‘email‘]."<br>"; print "password:".$_SESSION[‘password‘]; ?>
t(); } } ?> <html> <head> <title>login form</title> </head> <body> <h1>Login In</h1> <form action=‘create_session.php‘ method=‘post‘> <p>Email address:<input type=‘text‘ name=‘email‘ size=‘20‘></p> <p>Password:<input type=‘password‘ name=‘password‘ size=‘20‘></p> <p><input type=‘submit‘ name=‘submit‘ value=‘login‘></p> </form> </body> </html>
时间: 2024-10-13 12:33:30