登入界面
Posted wangzihao147
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了登入界面相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登入</title>
</head>
<body>
<?php
if ($_POST) {
$name = trim($_POST[‘name‘]);
$pasd = md5(trim($_POST[‘pasd‘]));
$cno = new mysqli(‘localhost‘, ‘root‘, ‘root‘, ‘aaa‘);
if ($cno->connect_error) {
echo $cno->error;
} else {
$sql = "select * from kaoshi where name = ‘$name‘ and mima = ‘$pasd‘";
$res = $cno->query($sql);
if (!$res) {
echo $cno->error;
} else {
if ($res->num_rows > 0) {
$arr = $res->fetch_assoc();
setcookie(‘admin‘,$arr[‘id‘]);
// var_dump($arr);
// 登入index
header(‘location:/index.php‘);
} else {
echo ‘账号或密码错误‘;
}
}
}
$cno->close();
};
?>
<form action="" method="post" >
账号:<input type="text" name="name" id="name"><br>
密码:<input type="password" name="pasd" id="pasd"><br>
<a href="http://www.q.com/zhuce.php" target="_blank">注册</a>
<input type="submit" name="" value="登入">
</form>
</body>
</html>
以上是关于登入界面的主要内容,如果未能解决你的问题,请参考以下文章