1)注册页面应包含基本的文本框、单选按钮、复选框、选择栏等元素,具体要求除提交按钮、重置按钮外,页面至少包含三种其他html控件 2)点击注册按钮时,要求对用户名(昵称)进行判空,如果用户未填写用户名(昵称),需要提示“请输入用户名!”; 3)若用户输入正确,请将注册信息展示在另外一个页面上; 4)在展示信息的页面上添加“修改(用户名)昵称”超链接,点击超链接进入修改用户名(昵称)的页面,并在该页面上显示原昵称,用户修改昵称后,点击提交按钮,跳转到新页面展示修改后的昵称。
时间: 2023-12-08 10:02:53 浏览: 27
以下是一个简单的实现上述要求的注册页面和展示页面的示例代码:
register.html:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册页面</title>
</head>
<body>
<h1>用户注册</h1>
<form action="register.php" method="post">
<label>用户名(昵称):</label>
<input type="text" name="username" required><br><br>
<label>密码:</label>
<input type="password" name="password" required><br><br>
<label>性别:</label>
<input type="radio" name="gender" value="male" checked>男
<input type="radio" name="gender" value="female">女<br><br>
<label>爱好:</label>
<input type="checkbox" name="hobby" value="reading">阅读
<input type="checkbox" name="hobby" value="music">音乐
<input type="checkbox" name="hobby" value="sports">运动<br><br>
<label>城市:</label>
<select name="city">
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
<option value="guangzhou">广州</option>
<option value="shenzhen">深圳</option>
</select><br><br>
<input type="submit" value="注册">
<input type="reset" value="重置">
</form>
</body>
</html>
```
register.php:
```php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册信息</title>
</head>
<body>
<?php
if(isset($_POST['username']) && $_POST['username'] != ''){
$username = $_POST['username'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$hobby = $_POST['hobby'];
$city = $_POST['city'];
echo "<h1>注册信息</h1>";
echo "<p>用户名(昵称):".$username."</p>";
echo "<p>密码:".$password."</p>";
echo "<p>性别:".$gender."</p>";
echo "<p>爱好:".$hobby."</p>";
echo "<p>城市:".$city."</p>";
echo "<a href='modify.php?username=".$username."'>修改(".$username.")昵称</a>";
}else{
echo "<script>alert('请输入用户名!');history.back();</script>";
}
?>
</body>
</html>
```
modify.php:
```php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改昵称</title>
</head>
<body>
<h1>修改(<?php echo $_GET['username']; ?>)昵称</h1>
<form action="modify_result.php" method="post">
<label>新昵称:</label>
<input type="text" name="new_username" required><br><br>
<input type="hidden" name="username" value="<?php echo $_GET['username']; ?>">
<input type="submit" value="提交">
<input type="reset" value="重置">
</form>
</body>
</html>
```
modify_result.php:
```php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改结果</title>
</head>
<body>
<?php
if(isset($_POST['new_username']) && $_POST['new_username'] != ''){
$new_username = $_POST['new_username'];
$username = $_POST['username'];
echo "<h1>修改结果</h1>";
echo "<p>原昵称:".$username."</p>";
echo "<p>新昵称:".$new_username."</p>";
}else{
echo "<script>alert('请输入新昵称!');history.back();</script>";
}
?>
</body>
</html>
```
以上代码实现了一个简单的注册页面和展示页面,其中包含了文本框、单选按钮、复选框、选择栏等元素,并对用户名进行了判空和展示注册信息的功能。在展示页面上添加了修改昵称的超链接,点击超链接可以进入修改页面,修改后跳转到新页面展示修改后的昵称。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)