SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

Retaining form data value after posting

Many times we have to show the visitors posted data in a form and show them the form again. This happens due to several reasons and one of the main reason is failure of entered data of the visitor matching to the required standard or specification. In an example say the visitor has entered all the details in a signup form but the user id entered by the member is already used by some one else. Such a situation can be checked only after the visitor enters his or her choice of id. In such a case we have to show one error message and ask the user to try one more user id. ( you can see how the signup form works with to total login script etc here ) Here if the user has already entered all other details like email, address, gender etc then it is not a good idea to ask the visitor to enter them again. We can retain the entered date in respective fields and ask for necessary change in selection of user id. So the main question is how to retain the value of the entered data in different components of the form. If some one has selected female as gender then the form should retain that value and by default should show female as selected. Same way all input text box, drop down list box and check box should retain the value already entered by the user.

There are different ways to post back the entered data of a form, we can use database also. But here we will get the value back in the form through query string and use the variable to store the data in PHP. There are some other methods which uses session and some other store in cache or cookies. Using query string is a better option as it list dependant on the client side conditions like cookies not accepting, cache full etc.

We will discuss post back of data of each component of a form. We will start with a simple text box and move to other form components like period button, drop down list, text area and check box. We will focus one component in one tutorial and at the end we will create one form using all the components using all our learning.

We will start with retaining value of a text box component of a form.

Discuss this tutorial at forum


Further readings
All form components validation with post back and data locking
Checkbox
How to retain form data if validation fails?
How to retain data of a text box after submitting
Retaining status of a check box
Updating checkbox value from & to a table record.
Retaining selected data of a period button of a form
Retaining selected data of a drop down list box of a form
Validating Date: Checking if date exist
Email address validation in a form
PHP Form Validation
is_numeric to check numeric numbers
ctype_alnum to check alphanumeric characters data
ctype_alpha to check alphabetic characters data
How to take care of form & query string variables if Register global is OFF?














 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.