Link to home
Start Free TrialLog in
Avatar of rround
rround

asked on

How to stop the refereshing of form fields

Hello,

I have a web form with quite a few fields (name, address etc). It's posts the data to a mysql database. When the form is filled in and there is a duplicate name, I echo a message to the user that the username already exists. However, the problem I have is with the other fields. All the info they entered (about 20 fields worth) is deleted and they have to retype them.  I want the user not to have to re-fill out all the fields. How can I achieve this?

Thanks in advance.

Rob.
Avatar of Batalf
Batalf
Flag of United States of America image

Maybe something like this?

<form action="<? echo $PHP_SELF; ?>" method="post">
<table border="0">
<tr><td><p>Firstname:</td><td><input type="text" size="20"  name="firstname" value="<? echo $firstname; ?>"></td></tr><tr><td><p>Lastname:</td><td><input type="text" size="20"  name="lastname" value="<? echo $lastname; ?>"></td></tr>
<tr><td><p>Address:</td><td><input type="text" size="30"  name="address" value="<? echo $address; ?>"></td></tr>


.. and so on
</table>
</form>

Doing this, the form would be posted to the same file, and the previous values is pretyped into the fields(eg: value="<? echo $firstname; ?>"> ).

Batalf
ASKER CERTIFIED SOLUTION
Avatar of Hamlet081299
Hamlet081299

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rround
rround

ASKER

Thanks Hamlet,

That was what I was looking for. Thanks for your input too Batalf.

Rob.
Avatar of rround

ASKER

Thanks Hamlet,

That was what I was looking for. Thanks for your input too Batalf.

Rob.