1
0
Fork 0
php-coding/11.test2.php

55 lines
1.5 KiB
PHP

<?php
session_start();
if (isset($_SESSION['role'])) {
echo '<script>alert("你已经登录,不需要再次登录");location.href="11.test2.default.php";</script>';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>用户登录</title>
</head>
<body>
<form action="11.test2.default.php" method="post" id="login_form1">
<table>
<tr>
<td>
<label for="username1">用户名</label>
</td>
<td>
<input type="text" name="username" id="username1" required>
</td>
</tr>
<tr>
<td>
<label for="password1">密码</label>
</td>
<td>
<input type="password" name="password" id="password1" required>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center">
<input type="submit" name="submit" id="submit1" value="登录" oninput="return check(form)">
<input type="reset" name="reset" id="reset1" value="重置">
</td>
</tr>
</table>
</form>
<script>
function check(login) {
if (login.username.value === "") {
alert("用户名不能为空");
form.username.focus();
return false;
}
if (login.password.value === "") {
alert("密码不能为空");
form.paasword.focus();
return false;
}
form.submit();
}
</script>
</body>