CSS 样式
css
body {font-family: Arial, sans-serif;
}.container {width: 400px;margin: 0 auto;padding: 20px;
}form {display: flex;flex-direction: column;gap: 10px;
}label {width: 100px;margin-right: 10px;
}input {width: 200px;padding: 5px;
}input[type="submit"] {background-color: 008CBA;color: white;cursor: pointer;
}php 登录脚本
php
query($sql);// 如果查询结果不为空,则登录成功,否则登录失败
if ($result->num_rows > 0) {$_SESSION['username'] = $username;header("Location: dashboard.php");exit;
} else {echo "用户名或密码错误!";
}// 关闭数据库连接
$mysqli->close();
?>