愿浪飒精神伴你左右,网络安全之路任重而道远。

登陆注册系统

Web渗透学习笔记 langsa 3年前 (2021-11-11) 705次浏览 0个评论
文章目录[隐藏]

代码共四个文件

1.loginsign.html

<html>
<head>
<meta charset="utf-8">
<title>登陆注册系统</title>
</head>
<h1>欢迎来到登陆注册系统</h1>
<h2>welcome to login and sign system</h2>
<form action="loginsign.php" method="POST">
  帐号  <input type="text" name='username'/><br /><br />
  密码  <input type="password" name='password'/> <br /><br />
  登陆<input type="submit" value="login"/>
</form>
<form action="sign.html">
 注册<input type="submit" value="sign"/>
</form>
</html>

2.sign.html

<html>
<head>
<meta charset="utf-8">
<title>注册系统</title>
</head>
<h1>欢迎新用户</h1>
<form action="sign.php" method="POST">
  请输入你的帐号  <input type="text" name='username'/><br /><br />
  请输入你的密码  <input type="password" name='password'/> <br /><br />
  确认注册<input type="submit" name= 'sign' value="sign"/>
</form>
<form action="loginsign.html">
    <input type="submit"  value="返回登陆"/>
</form>
</html>

3.loginsign.php

<meta charset="utf-8">
<?php
$username = $_POST['username'];//获取传参
$password = $_POST['password'];
$con = mysqli_connect('localhost','phpwebtest','phpwebtest','phpwebtest');
mysqli_select_db($con,'phpwebtest');//连接数据库
$sql="select*from users where username ='$username' and passwd ='$password'";//执行sql语句
$result=mysqli_query($con,$sql);//得到查询结果 object
if ($username== NULL or $password == NULL) {
    echo '帐号或密码为空,请重新登陆';
 }
elseif(mysqli_fetch_array($result)['username']==$username){
    echo '登陆成功';
}
else{
    echo '该帐户不存在,请返回注册完成后再登陆';
}
//转换为数组,判断输入的正确与否
?>

4.sign.php

<?php
$sign = $_POST['sign'];
$username = $_POST['username'];//获取传参
$password = $_POST['password'];
if (($username or $password) != NULL) {
$con = mysqli_connect('localhost','phpwebtest','phpwebtest','phpwebtest');
mysqli_select_db($con,'phpwebtest');//连接数据库
$sql="insert into users value('$username','$password')";//执行sql语句
$result=mysqli_query($con,$sql);//得到结果 object
echo '注册成功,请返回登陆';
}else {
    echo '请输入正确的密码完成注册!';
}
?>

功能展示

1.随便输入账号密码

img

跳转新页面返回如下:

img

2.不输入或填写不完整登陆

img

img

跳转新页面返回如下:

img

3.注册

img

img

留空填写注册会返回

img

输入正确注册:

img

img

点击返回登陆

img

4.登陆

img

提示登陆成功


本文标题:登陆注册系统
本文链接:https://blog.langsasec.cn/index.php/2021/11/12/phploginsignsystem/
版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
喜欢 (2)
[]
分享 (0)
langsa
关于作者:
一个网络安全从业人员
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址