php -- session

----- 012-form.html -----

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>一个PHP网页</title>
</head>
<body>
<center>
    <form action="012-session.php">
        用户名:<input type="text" name="username"/><br/>&nbsp;&nbsp;码:<input type="text" name="password"/><br/>
        <input type="submit" name="submit" value="登录"/>
        <input type="reset" name="reset" value="重置"/>
    </form>
</center>
</body>
</html>

----- 012-session.php -----

 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta http-equiv="content-type" content="text/html; charset=utf-8">
 5     <title>一个PHP网页</title>
 6 </head>
 7 <body>
 8 <?php
 9     echo "保存会话<br/>";
10     session_start();
11     $_SESSION[‘username‘] = $_GET[‘username‘];
12     $_SESSION[‘password‘] = $_GET[‘password‘];
13     echo "现在的会话内容是:<br>";
14     echo "用户名:", $_SESSION[‘username‘], "<br/>";
15     echo "密码:", $_SESSION[‘password‘], "<br/>";
16 ?>
17 </body>
18 </html>

php -- session,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。