请用php和html写一个登陆系统
下面是一个简单的PHP和HTML登陆系统的示例代码:
<?php
// 检查是否已经提交表单
if(isset($_POST['submit'])){
// 获取用户输入的用户名和密码
$username = $_POST['username'];
$password = $_POST['password'];
// 在这里可以添加验证用户名和密码的逻辑
// 例如,可以查询数据库来验证用户名和密码
// 假设用户名和密码都是正确的
$message = "登陆成功!";
}
?>
<!DOCTYPE html>
<html>
<head>
<title>登陆系统</title>
</head>
<body>
<h2>登陆</h2>
<?php if(isset($message)){ echo $message; } ?>
<form method="POST" action="">
<label for="username">用户名:</label>
<input type="text" name="username" id="username" required><br>
<label for="password">密码:</label>
<input type="password" name="password" id="password" required><br>
<input type="submit" name="submit" value="登陆">
</form>
</body>
</html>
注意:这只是一个简单的示例,实际的登录系统需要更复杂的逻辑来验证用户名和密码,并且可能还需要添加其他的安全性措施,例如防止SQL注入和密码哈希存储等
原文地址: http://www.cveoy.top/t/topic/iSZQ 著作权归作者所有。请勿转载和采集!