登陆界面(index.html):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h2>登陆界面</h2>
<form name="input" action="./welcome.php" method="get">
<label>用户名:</label><input class="text" type="text" name="username" />
<label>密码:</label><input class="text" type="password" name="password" />
<input class="submit" type="submit" name="submit" value="登录" />
</form>
</body>
</html>
数据库连接(welcome.php):
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<?php
$username = $_GET['username'];
$password = $_GET['password'];
if($username==NULL or $password==NULL){echo "用户名或密码不能为空,请重新输入";}
else{
$link = mysqli_connect('127.0.0.1','root','root','test');
if(!$link){
die("连接失败:".mysqli_connect_erro());
}
echo "数据库连接成功";
$sql="select * from test.users where username='$username'and password='$password'";
$result=mysqli_query($link,$sql);
$row=mysqli_fetch_assoc($result);
if($row){
echo "登录成功,欢迎".$username."!";
}
else{
echo "登录失败!<a herf='test.php'>重新登陆";
}
}
?>
数据库(SQL_Front):