注册界面
<!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['name']; $dw = md5($_POST['dw']); require_once "../ZY/YIN.class.php"; $db = new YIN(); $obj = "select count(*) from zc WHERE uname = '{$name}'"; $data = $db->StrQuery($obj); //var_dump($data); if ($data!='0'){ exit("用户名重复"); }else{ $sql = "insert into zc VALUES (NULL,'{$name}','{$dw}','')"; $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['uname']; $m = $_POST['m'];//var_dump($_POST);require_once "YIN.class.php";$db = new YIN(); $obj = "select count(*) from zc WHERE uname = '{$name}'"; $data = $db->StrQuery($obj,1); //var_dump($data); if ($data != "0" ){// echo "成功"; $obj_m = "select count(*) from zc WHERE pad = '{$m}'"; $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中文网其他相关文章!