Retaining form data value after posting

Retaining text box value
Retaining checkbox value
Retaining dropdown list
Retaining period button
Using JavaScript to retain data

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 or failure of data validation.

DEMO : Form all components validation and post back

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 dependent 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 DEMO form using all the components using all our learning.

Retaining value of a text box component of a form


PHP Form Listbox in a Form using PHP Checkbox in PHP Radio buttons

Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com







    Rajesh

    22-06-2012

    I want to design a form where user select one option of a drop down then the same table is searched and then the next drop down box shows only those options related to first drop down selection as for example we have a medicine table where name,code,date-of-exp,quantity fields are there in first drop down all medicine name should appear , when one select one medicine then all exp date [there is a possibility that for one medicine different exp dates medicine is available] of selected medicine should display , when one select one exp date then all medicine of this exp date should appear. Pl advice

    Post your comments , suggestion , error , requirements etc here





    PHP video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer