<?php header("content-type:text/html; charset=utf-8"); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> .box{ width: 500px; margin: 0 auto; } .grid{ border:1px solid #d9211f; background-color: #fff5ec; margin-top:30px; } h3{ text-align: center; } </style> </head> <body> <div> <h3>1227粘性表单案例</h3> <hr> <form action="" method="POST"> <h3>用户注册</h3> 用户名:<input type="text" id="userName" name="userName" value="<?php echo isset($_POST['userName'])?$_POST['userName']:'' ?>"> <br> 密 码:<input type="password" id="passWord" name="passWord" value="<?php echo isset($_POST['passWord'])?$_POST['passWord']:'' ?>"> <br> 性 别:<input type="radio" name="gender" value="male" <?php echo (isset($_POST['gender'])&&$_POST['gender']=='male')?'checked':''?>>男 <input type="radio" name="gender" value="female" <?php echo (isset($_POST['gender'])&&$_POST['gender']=='female')?'checked':''?>>女 <br> 学 历:<select name="degree" id="degree"> <option value="primary" <?php echo (isset($_POST['degree'])&&$_POST['degree']=='primary')?'selected':'';?>>初级</option> <option value="middle" <?php echo (isset($_POST['degree'])&&$_POST['degree']=='middle')?'selected':'';?>>中级</option> <option value="senior" <?php echo (isset($_POST['degree'])&&$_POST['degree']=='senior')?'selected':'';?>>高级</option> </select> <br><br> 备 注:<textarea name="mark" id="mark" cols="30" rows="10"><?php echo isset($_POST['mark'])?$_POST['mark']:''?></textarea> <br><br><br> <button>提交</button> </form> </div> </body> </html>