Page 1 of 1
Showing message on same page
Posted: Tue Apr 27, 2010 3:44 pm
by binarycodes
I have a form i designed for collecting the details of users, if the details submitted to database a summary page is displayed, b4 this form can be submitted to the database i check to know if the username of the user already exists, if yes i want a message (e.g "username exists") to be displayed in front of the username field on the same page. Please how do i achieve this?
Please i need all your help...
Re: Showing message on same page
Posted: Tue Apr 27, 2010 4:43 pm
by jraede
On your form handler, save all of the values that the user input as session variables. Then you can run checks to validate the user input. If the username is already taken, for instance, you can set $_SESSION['form_errors'][] = "Sorry, this username is already taken.". If there's an error, take them back to the form page, populate the input fields with the form values from the session, and then display any errors in the $_SESSION['form_errors'] array.
PHP Sessions