Home > Article > Backend Development > PHP hardcoded login form example
This article introduces an example of hard-coded login in PHP. Friends in need can refer to it.
A simple example of php implementing user login. Code: <HTML> <BODY> <FORM METHOD="POST" ACTION="LoginFormAction.php"> <H2>php用户登录页面-bbs.it-home.org</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>"; } ?> --> |