Hello friends
i am working on php page. There are around 20 fields like....
<label>4. First Name</label>
<input type="text" name="fnam" size="10" value="<?php if (isset($_POST['submit'])) echo $_POST['fnam'];?>"><br><br>
<label>5. Basic Pay</label>
<input type="text" name="basic" value="<?php if (isset($_POST['submit'])) echo $_POST['basic'];?>">
</select> <br> <br>
when i click on submit button the data are inserting in the data base but after that also value remain in the textbox....the value should clear out whenever i click on submit or when i refresh......but its not happning.....please help me to solve this problem
thanks
form not clearing data fields
Moderator: General Moderators
-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
Re: form not clearing data fields
Remove the code inside the value="..." attribute.
-
om.bitsian
- Forum Commoner
- Posts: 36
- Joined: Wed Sep 09, 2009 4:13 am
Re: form not clearing data fields
i have around 20 entries in my form... when i will remove it and suppose there is a validation in some 15th field.......all the fields will be clear and again i have to enter all the values......do you have any alternate solution for it????????
thanks
thanks
Re: form not clearing data fields
Look at your code - if the form has been submitted, it will always display the posted data, despite an error, or success.
You could process the form before displaying it (if the form has been submitted), and then set a variable to true on success, or false on failure. Then, also check that the variable is false before displaying the posted data in the form.
You could process the form before displaying it (if the form has been submitted), and then set a variable to true on success, or false on failure. Then, also check that the variable is false before displaying the posted data in the form.