Home > Backend Development > PHP Tutorial > Case study of php implementation of login and registration

Case study of php implementation of login and registration

黄舟
Release: 2023-03-16 19:12:01
Original
2105 people have browsed it

Registration interface


<!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>
Copy after login

Registration processing interface

<?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 "注册成功";
}
Copy after login

Login interface

<!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>
Copy after login

Login processing


<?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>
Copy after login

The above is the detailed content of Case study of php implementation of login and registration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template