This article mainly introduces the implementation case of PHP registration and login interface. Interested friends can refer to it. I hope it will be helpful to everyone.
At first I thought the two functions of registration and login on a website were magical. Later, I did some research and found that the truth is actually very simple. Let’s take a look at how to implement it. . . .
I created several files on my computer:
login.html (login page)
register.html (Registration page)
success.html (Login success redirect page)
return.html (Registration success page )
login.php
register.php
Login interface and registration interface and success.html are combined There is no
, everything is just some html tags as follows:
return.html is the page that appears after successful registration. There is a js code in it that is used to return to the login interface regularly
无标题文档 注册成功!
5秒后返回登录界面
你也可以直接点击回到登录页面
register.php It is the background page corresponding to the registration page
"."window.alert"."("."\""."请填写完成!"."\"".")".";".""; echo""; exit; } if($password1==$password2)//确认密码是否正确 { $str="select count(*) from register where username="."'"."$name"."'"; $result=mysql_query($str,$link); $pass=mysql_fetch_row($result); $pa=$pass[0]; if($pa==1)//判断数据库表中是否已存在该用户名 { echo""; echo""; exit; } $sql="insert into register values("."\""."$name"."\"".","."\""."$password1"."\"".")";//将注册信息插入数据库表中 //echo"$sql"; mysql_query($sql,$link); mysql_query('SET NAMES UTF8'); $close=mysql_close($link); if($close) { //echo"数据库关闭"; //echo"注册成功!"; echo""; } } else { echo""; echo""; } } } } ?>
login.php login interface corresponding to the background file
"."window.alert"."("."\""."请填写正确的信息!"."\"".")".";".""; echo""; exit; } $str="select password from register where username="."'"."$name"."'"; mysql_query('SET NAMES UTF8');20 $result=mysql_query($str,$link); $pass=mysql_fetch_row($result); $pa=$pass[0]; if($pa==$password)//判断密码与注册时密码是否一致 { echo"登录成功!"; echo""; } { echo""; echo""; } } } } ?>
I still have a lot to improve when I have nothing to do. You are welcome to ask questions and discuss and provide easier methods!
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
phpWhat are the steps to use redis long connection
phpDetailed explanation of application containerization and deployment
##phpHow to implement data export
phpSimple winning algorithm example
##
The above is the detailed content of Implementation case of php registration and login interface. For more information, please follow other related articles on the PHP Chinese website!