php让页面记住表单提交后的信息方法

<body>
<?php
$name = $_POST['name'];
echo $name;
$gender = $_POST['gender'];
echo $gender;
?>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
Name: <input type="text" name="name" value="<?php echo $name;?>">
female:<input type="radio" name="gender"
<?php if (isset($gender) && $gender=='female') echo 'checked' ?> value="female">
<input type="submit" name="submit" value="提交">
</form>

ui界面:

 

后记:

注意要先获取变量才能输出变量,顺序别搞错

posted @ 2019-01-21 20:22  凯宾斯基  阅读(237)  评论(0编辑  收藏  举报