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>
Advertisement
Answer
You have to give all the input boxes a value attribute equal to the previously submitted value.
<td><input type="text" size="30" name="exp" id="exp" value="<?=$exp?>" /></td> <td>Expire</td>