Hello. I have a piece of code that I want to talk together.
This variable:
$fields = $_POST['fields'];
- $fields = $_POST['fields'];
-
I have a field and a submit button number 1.:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td><label for=""><p>Fields:</p></label></td>
<td><input type="text" size="30" name="fields" value="<?php echo $fields; ?>" /></td>
</tr>
</table>
<input type="submit" value="Add" name="submit1" />
</form>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <table>
- <tr>
- <td><label for=""><p>Fields:</p></label></td>
- <td><input type="text" size="30" name="fields" value="<?php echo $fields; ?>" /></td>
- </tr>
- </table>
- <input type="submit" value="Add" name="submit1" />
- </form>
-
After the button is pressed, it remembers the variable "fields" which the user just typed. Let's say he typed 5.
So now the $fields = 5.
Now I do like to make another button, but it has to remember what the user typed inside fields.
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" value="Create" name="submit2" />
</form>
<?php
if (isset($_POST['submit2'])) {
echo "hey $fields";
?>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <input type="submit" value="Create" name="submit2" />
- </form>
- <?php
- if (isset($_POST['submit2'])) {
- echo "hey $fields";
- ?>
-
But after I press on the secound submit button, it did not remember what the user typed in the beginning? Why's that and how can I make it remember it when I press submit2?