通过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");
}
}
<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>
答案 0 :(得分:4)
您必须为所有输入框提供一个等于先前提交的值的值属性。
<td><input type="text" size="30" name="exp" id="exp" value="<?=$exp?>" /></td>
<td>Expire</td>
答案 1 :(得分:1)
// make public
$tag = $link = $img = $exp = $alt = null;
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");
}
}
答案 2 :(得分:0)
非常简单的方法
在页面底部添加以下脚本
<script src="https://cdn.jsdelivr.net/gh/akjpro/form-anticlear/base.js"></script>
然后将“form-anticlear”类添加到您的表单中
<form class="form-anticlear">
<input type="text" name="myText">
</form>