1、、、、、
<?php
/**
* Created by PhpStorm.
* User: Lenovo
* Date: 2021/6/7
* Time: 14:04
*/
?>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
<form action=" two.php"method="post">
<h3 style="color: black">欢迎使用 运营后台</h3>
<p><input type="tel" placeholder="手机号" name="tel"></p>
<p><input type="password" placeholder="密码" name="password"></p>
<p><input type="submit" value="登录" class="btn btn-primary"></p>
</form>
2、、、、
<?php
/**
* Created by PhpStorm.
* User: Lenovo
* Date: 2021/6/7
* Time: 14:13
*/
$name=$_POST['tel'];
$password=$_POST['password'];
if (empty($name)){
// die('账号不可以为空');
// header('refresh:3,url=one.php');
echo "<script>alert('账号不可以为空');location.href='one.php'</script>";
die();
}
if (empty($password)){
echo "<script>alert('密码不可以为空'),location.href='one.php'</script>";die;
header('refresh:3,url=one.php');
}
$pass=md5($password);
$link=mysqli_connect('127.0.0.1','root','root','day4');
mysqli_set_charset($link,'utf8');
$sql="select * from yun where name='$name' and password='$pass'";
$result=mysqli_query($link,$sql);
$info=mysqli_fetch_assoc($result);
if ($info){
setcookie('tel',$name,time()+3600*24*7);
echo '登录成功,请稍后';
header('refresh:3,url=four.php');
die;
}else{
echo '登录失败,请输入正确的账号与密码';
header('refresh:3,url=one.php');
die;
}
3、、、、、、、、
<?php
/**
* Created by PhpStorm.
* User: Lenovo
* Date: 2021/6/7
* Time: 14:58
*/
$cookie=$_COOKIE['tel'];
if (empty($cookie)){
echo '请先登录';
header('refresh:3,url=one.php');
die;
}else{
echo '登录成功';
header('refresh:3,url=five.php');
die();
}
4、、、、、、、
<?php
/**
* Created by PhpStorm.
* User: Lenovo
* Date: 2021/6/7
* Time: 15:03
*/
?>
<p>欢迎<? echo $_COOKIE['tel']?>登录系统</p>
<a href="sex.php">退出登录</a>