html – Prevent form reset after submit php-ThrowExceptions

Exception or error:

I have a dynamically populated table. Up on form submit I would like to keep the new values in the textfield of the form. After a search on Stack Overflow I found this

<form name="test" method="post">
Your Name: <input type="text" name="YourName" <?php if (isset($_POST['YourName'])) echo        'value="'.$_POST['YourName'].'"';?> >

I tried to adapt in to my form but was unable to do so. The textfield is still reset after button is clicked.

echo "<td width=40%><input type=text value='$location'"; 
if (isset($_POST['$dynamic_location'])) echo "value=".$_POST['$dynamic_location']; 
echo "name='$dynamic_location'></td>\n";             
How to solve:

For the new values to keep up in the fields you how to add another query to fetch the data from the database and echo it in its individual fields.

And remember to fetch only the fields needed that will increase your execution time.


If action="" or not set at all, following should work

if (isset($_POST['$dynamic_location'])) echo "value=".$_POST['$dynamic_location']; 
echo "name='$dynamic_location'/>";

If action="another_file.php" , you can do this
In another_file.php


On current file or previous_page.php

if (isset($_GET['dynamic_location'])) echo "value=".$_GET['dynamic_location']; 
echo "name='$dynamic_location'/>";

Leave a Reply

Your email address will not be published. Required fields are marked *