制作一个登录表单,在做一个action的跳转界面,题是欢迎登陆
时间: 2024-03-02 16:50:24 浏览: 17
好的,以下是一个简单的登录表单示例,使用POST方法提交表单,跳转到一个欢迎页面:
```
<!DOCTYPE html>
<html>
<head>
<title>登录表单</title>
</head>
<body>
<h2>登录</h2>
<form method="POST" action="welcome.php">
<label for="username">用户名:</label>
<input type="text" name="username" id="username" required><br><br>
<label for="password">密码:</label>
<input type="password" name="password" id="password" required><br><br>
<input type="submit" value="登录">
</form>
</body>
</html>
```
在上面的表单中,我们使用了POST方法提交表单,并将表单数据提交到了`welcome.php`页面。当用户点击登录按钮时,表单数据会被提交到服务器端,服务器端可以对提交的数据进行验证,然后根据验证结果跳转到不同的页面。下面是`welcome.php`页面的示例代码,用于显示欢迎信息:
```
<!DOCTYPE html>
<html>
<head>
<title>欢迎登陆</title>
</head>
<body>
<h2>欢迎登陆</h2>
<?php
$username = $_POST['username'];
echo "欢迎您,".$username."!";
?>
</body>
</html>
```
在上面的代码中,我们使用了PHP语言获取了通过POST方法提交的表单数据,并将用户名显示在了欢迎信息中。当用户登录成功后,会跳转到这个页面,显示欢迎信息。