Hi guys
I have an input form related problem, I simplyfy it by just showing an example with 1 field.
So there is a panel where the user can enter certain informations eg name, birth, address etc and
he can preview all the entered information (as many times he likes) just like a comment editor.
Every time he pushes the preview button a preview will be generated on the bottom of the page.
In order to not to reset out all the fields what he entered I store the data in session variables.
If he modifies the field again the session variable will be updated.
Here is a snippet about how did I implement this:
echo '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
echo '<br><input name="data1" size="50" value="'.$_SESSION['data1'].'"><br>';
echo '<br><input type="submit" name="prv" value="Preview">';
echo '</form>';
if (isset($_POST['prv']))
{
if (strcmp($_SESSION['data1'], $_POST['data1']) != 0 ) $_SESSION['data1'] = $_POST['data1'];
$data1 = $_SESSION['data1'];
...
validate input data
...
}
The problem is that this doesn't behaves as it expected. Once the user hits the preview button it shows the output right
but for next time all the forms are empty, after that it's right again. It acts like it would store down everything twice. If I fill out the empty forms
their content is saved too.