How to write php login?
1. First create a login form. (This is all HTML, no explanation).
<form action="" method="post"> <input type="text" name="username" /><br> <input type="password" name="pwd" /><br /> <input type="submit" name="login" value="登录" /> </form>
2. Start writing the PHP processing program, and start writing on top of the code you just wrote:
$username = "admin"; //要登录的账号 $pwd = "123456"; //要使用的密码 if ($username==$_POST[username]&&$pwd==$_POST[pwd]){ echo "登陆成功!"; }else{ echo "账号或密码错误"; exit(); }
In fact, this is a very simple user system.
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to write php login. For more information, please follow other related articles on the PHP Chinese website!