Form field display problem

From: Mr Mint (mrmint_at_fresca.com)
Date: 11/29/03


Date: Sat, 29 Nov 2003 03:49:00 +0100

Buenos días,

I cannot solve a problem that has been bugging me for some while now and
have not managed to resolve it by using my usual resources. Even trial and
error has failed me. I would be grateful if some of you would take a look at
the following and be able to offer some assistance. I hope to have conveyed
the problem well enough.
TIA

The procedure:
- A user enters a name and surname in the appropriate fields on a form. The
form has no other fields.
- After a user has clicked submit they will be presented with the table
data.
(The name and surname fields now display whatever the user typed - see the
two code snippets).

The problem:
If the user now enters a different name and surname into the name and
surname fields then presses submit, the new table data will be displayed,
but the name and surname fields now contain the original data.
Now, if the user immediately makes alternate clicks on the Submit button,
the data in the name and surname fields switches it content. First showing
the original name and surname, then the second name surname pair.

ff.html
-------
<form name="ff_form" method="post" action="">
<?php print TXT_NAME; ?>

<input type="text" name="name" value="<? print "$ff_name"; ?>">

<?php print TXT_SURNAME; ?>

<input type="text" name="surname" value="<? print "$ff_surname"; ?>">

<input type="submit" name="submit" value="<?php print TXT_FIND; ?>">
<br>
<p align="center">
<?php
        if (isset($_POST['submit'])) {
        include('ff.php');
}
?>

-------------------

ff.php
------
<?php
// The variable ff_name, ff_surname are needed as a condition further down
the page redirects to a new page if no data is found.

if ($_POST['name'] == "" || $_POST['surname'] =="") {
        error_box($FF_NAME_SURNAME, $msg2);
}

else {
        $ff_name = strip_tags(trim($_POST['name']));
        $ff_surname = strip_tags(trim($_POST['surname']));
        session_register('ff_name');
        session_register('ff_surname');

        // connect to DB and select table and search for matching records
 // If records are found format and display the data in a table
}

--------------------

Cedric Edwards


Quantcast