php实现用户登录的简单例子。
代码:
<HTML> <BODY> <FORM METHOD="POST" ACTION="LoginFormAction.php"> <H2>php用户登录页面-www.jb200.com</H2> <BR><BR> 用户名: <BR><INPUT TYPE="TEXT" NAME="username" SIZE="16"> <BR><BR> 密 码: <BR><INPUT TYPE="PASSWORD" NAME="password" SIZE="16"> <BR><BR> <BR><BR> <INPUT TYPE="SUBMIT" VALUE="提交"> </FORM> </BODY> </HTML> <!-- LoginFormAction.php <?php $passwords = array("name1" =>"pass1", "name2" =>"pass2"); if ($password == $passwords[$username]){ setcookie("username", $username, time()+1200); echo "<H2>授权访问成功.</H2>"; }else{ setcookie("username", "", time()-3600); echo "<H2>用户名与密码验证失败.</H2>"; } ?> -->