php实现登陆与注册的案例

黄舟
发布: 2023-03-16 19:12:01
原创
2101 人浏览过

注册界面


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form action="conduct.php" method="post">
    <input type="text" name="name" placeholder="用户名">
    <input type="password" name="dw" placeholder="密码">
    <input type="submit" value="提交">
</form>
</body>
</html>
登录后复制

注册处理界面

<?php

$name = $_POST[&#39;name&#39;];
$dw = md5($_POST[&#39;dw&#39;]);
require_once "../ZY/YIN.class.php";
$db = new YIN();
$obj = "select count(*) from zc WHERE uname = &#39;{$name}&#39;";
$data = $db->StrQuery($obj);
//var_dump($data);
if ($data!=&#39;0&#39;){
    exit("用户名重复");
}else{
    $sql = "insert into zc VALUES (NULL,&#39;{$name}&#39;,&#39;{$dw}&#39;,&#39;&#39;)";
    $data = $db->Query($sql,0);
    echo "注册成功";
}
登录后复制

登陆界面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form method="post" action="dlcl.php">
    <input type="text" name="uname" placeholder="用户名">
    <input type="password" name="m" placeholder="密码">
    <input type="submit" value="登陆">
</form>

</body>
</html>
登录后复制

登陆处理


<?php
$name = $_POST[&#39;uname&#39;];
$m = $_POST[&#39;m&#39;];//var_dump($_POST);require_once "YIN.class.php";$db = new YIN();
$obj = "select count(*) from zc WHERE uname = &#39;{$name}&#39;";
$data = $db->StrQuery($obj,1);
//var_dump($data);
if ($data != "0" ){//    
echo "成功";
$obj_m = "select count(*) from zc WHERE pad = &#39;{$m}&#39;";
$data_m = $db->StrQuery($obj_m,1);
if ($data_m!="0"){//    var_dump($data_m);
    echo "登陆成功";
}else{    header("location:denglu.php");
}
}else{    header("location:denglu.php");
}?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
登录后复制

 

以上是php实现登陆与注册的案例的详细内容。更多信息请关注PHP中文网其他相关文章!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板