提交后不要重置表单值
通过 php 标头代码进行预览后,我不想重置输入框?谢谢。 这是我的简化代码:
#php Code
if($_POST['pre']){
$tag = $_POST['tag'];
$link = $_POST['link'];
$img = $_POST['img'];
$exp = $_POST['exp'];
$alt = $_POST['alt'];
if ( $tag == '' or $img == '' or $alt==''){
}
else{
$_SESSION['pre'] = "<a href=" ;
$_SESSION['pre'] .= "\"$link\"><img src=";
$_SESSION['pre'] .= "\"$img\" alt=\"$alt\" ></a>";
header("location: add_adv.php?show=on");
}
}
html 代码
<table>
<tr><td id="title"><p>add</p></td></tr>
<tr><td></td></tr>
<tr>
<td><form name="form2" method="post" action="">
<table>
<tr>
<td><input type="text" name="tag" id="tag" /> </td>
<td>tag</td>
</tr>
<tr>
<td><input type="text" size="30" name="img" id="img" /></td>
<td>picture</td>
</tr>
<tr>
<td><input type="text" size="30" name="link" id="link" /></td>
<td>link</td>
</tr>
<tr>
<td><input type="text" size="30" name="alt" id="alt" /></td>
<td>alternative</td>
</tr>
<tr>
<td><input type="text" size="30" name="exp" id="exp" /></td>
<td>Expire</td>
</tr>
<tr>
<td><input name="pre" type="submit" class="sub" id="pre" value="Preview">
<input type="submit" name="add_adv" class="sub" id="add_adv" value="اضافه" /></td>
<td></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
After giving a preview by php header code, I want to not reset the input boxes? Thanks.
This is my simplified code:
#php Code
if($_POST['pre']){
$tag = $_POST['tag'];
$link = $_POST['link'];
$img = $_POST['img'];
$exp = $_POST['exp'];
$alt = $_POST['alt'];
if ( $tag == '' or $img == '' or $alt==''){
}
else{
$_SESSION['pre'] = "<a href=" ;
$_SESSION['pre'] .= "\"$link\"><img src=";
$_SESSION['pre'] .= "\"$img\" alt=\"$alt\" ></a>";
header("location: add_adv.php?show=on");
}
}
html Code
<table>
<tr><td id="title"><p>add</p></td></tr>
<tr><td></td></tr>
<tr>
<td><form name="form2" method="post" action="">
<table>
<tr>
<td><input type="text" name="tag" id="tag" /> </td>
<td>tag</td>
</tr>
<tr>
<td><input type="text" size="30" name="img" id="img" /></td>
<td>picture</td>
</tr>
<tr>
<td><input type="text" size="30" name="link" id="link" /></td>
<td>link</td>
</tr>
<tr>
<td><input type="text" size="30" name="alt" id="alt" /></td>
<td>alternative</td>
</tr>
<tr>
<td><input type="text" size="30" name="exp" id="exp" /></td>
<td>Expire</td>
</tr>
<tr>
<td><input name="pre" type="submit" class="sub" id="pre" value="Preview">
<input type="submit" name="add_adv" class="sub" id="add_adv" value="اضافه" /></td>
<td></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须为所有输入框指定一个等于先前提交的值的值属性。
You have to give all the input boxes a value attribute equal to the previously submitted value.
非常简单的方法
在页面底部添加以下脚本
然后将“form-anticlear”类添加到您的表单中
访问高级选项:https://github.com/akjpro/form-anticlear
Very simple method
Add below script in bottom of your page
Then add 'form-anticlear' class to your form
Visit for advanced options : https://github.com/akjpro/form-anticlear