Home  >  Article  >  Backend Development  >  PHP hardcoded login form example

PHP hardcoded login form example

WBOY
WBOYOriginal
2016-07-25 08:56:311361browse
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>";
}
?>
-->


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn