示例图:
Ps.本人有点懒哈~ 就输出个成功算了吧~
代码里面注释写很详细了哦~ 废话不多说 直接上代码~
代码:
<!DOCTYPE htmgre满分l><html><head><meta chart="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Zhe - 注册登录</title><link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" /><script src="https://www.layuicdn.com/layui/layui.js" chart="utf-8"></script></head><body><fieldt class="layui-elem-field layui-field-title" style="margin-top: 20px;"><legend>Zhe - 登录注册演示</legend></fieldt> <div style="padding: 20px; background-color: #F2F2F2;"><div class="layui-row layui-col-space15"><div class="layui-col-md6"><div class="layui-card"><div class="layui-card-h五福如意eader">注册</一件开心的事div><div class="layui-card-body"><form class="layui-form" action="register.php" method="post" onsubmit="return checkForm(this)" lay-filter="example"><div class="layui-form-item"><label class="layui-form-label">输入框</label><div class="layui-input-block"><input type="text" name="urname" placeholder="请输入账号" class="layui-input"></div></div><div class="layui-form-item"><label class="layui-form-label">密码框</label><div class="layui-input-block"><input type="password" name="password" placeholder="请输入密码" class="layui-input"></div></div> <div class="layui-form-item"><div class="layui-input-block"><input type="submit" class="layui-btn layui-btn-normal" value="立即注册"/></div></div></form></div></div></div><div class="layui-col-md6"><div class="layui-card"><div class="layui-card-header">登录</div><div class="layui-card-body"><form class="layui-form" action="login.php" method="post" onsubmit="return checkForm(this)" lay-filter="example"><div class="layui-form-item"><label class="layui-form-label">输入框</label><div class="layui-input-block">&l12月你好说说t;input type="text" name="urname" placeholder="请输入账号" class="layui-input"></div></div><div class="layui-form-item"><label class="layui-form-label">密码框</label><div class="layui-input-block"><input type="password" name="password" placeholder="请输入密码" class="layui-input"></div></div> <div class="layui-form-item"><div class="layui-input-block"><input type="submit" class="layui-btn layui-btn-normal" value="立即登录"/></div></div></form></div></div></div></div></div><script type="text/javascript">// 验证输入不为空的脚本代码function checkForm(form) { if(form.urname.value == "") { alert("用户名不能为空!");form.urname.focus();return fal;}if(form.password.value == "") { alert("密码不能为空!");form.password.focus();return fal;}return true;}</script></body></html>
代码:
<?phpssion_start();header("content-type:text/html;chart=utf-8");//连接数据库$link = mysqli_connect("localhost","pay_com_cn","pay_com_cn","pay_com_cn");if (!$link) { die("连接失败: " . mysqli_connect_error());}//接收$_POST用户名和密码$urname = $_POST['urname'];$password = $_POST['password'];//查看表ur用户名与密码和传输值是否相等$sql = "SELECT * FROM ur WHERE urname = '$urname' AND password = '$password'";//result必需规定由 mysqli_query()、mysqli_store_result() 或 mysqli_u_result() 返回的结果集标识符。$result = mysqli_query($link,$sql);$num = mysqli_num_rows($result);//函数返回结果集中行的数量//判断是否登录后显示或跳转if($num){ echo '登录成功';}el{ echo'登录失败';}mysqli_clo($link);//关闭数据库?>
代码:
<?phpheader("content-type:text/html;chart=utf-8");//连接数据库$link = mysqli_connect("localhost","pay_com_cn","pay_com_cn","pay_com_cn");if (!$link) { die("连接失败: " . mysqli_connect_error());}//接收$_POST用户名和密码$urname=$_POST['urname'];$password=$_POST['password'];//查看表ur用户名是否存在或为空$sql_lect = "SELECT * FROM ur WHERE urname = '$urname'";//result必需规定由 mysqli_query()、mysqli_store_result() 或 mysqli_u_result() 返回的结果集标识符。$lect = mysqli_query($link,$sql_lect);$num = mysqli_num_rows($lect);//函数返回结果集中行的数量if($urname == "" || $password == ""){ echo "请确认信息完整性";}el if($num){ echo "已存在用户名";//已存在账户名输出错误}el{ $sql="inrt into ur(urname,password) values('$urname','$password')";$resu送苹果的含义lt=mysqli_query($link,$sql);//判断是否注册后显示内容if(!$result){ echo "注册不成功!"."<br>";//输出错误echo "<a href='index.php'>返回</a>";//超链接到首页}el{ echo "注册成功!"."<br/>";//输出成功echo "<a href='index.hphp'>立刻登录</a>";//超链接到首页}}?>
最后附上本文用到的mysql表
以上就是一个简单的PHP注册登录页面了~
非常感谢大家的关注支持~
原创不易,感谢支持
微信公众号:IR艾享窝
如果文章对你有帮助,记得一键三连哦~
本文地址:https://blog.csdn.net/weixin_45561522/article/details/111144973
本文发布于:2023-04-09 00:49:24,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/7fd932899d3afc4eef727b7496b124e3.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:PHP实现简单注册登录 详细全部代码.doc
本文 PDF 下载地址:PHP实现简单注册登录 详细全部代码.pdf
留言与评论(共有 0 条评论) |