Validating forms using php
Of course, we can ask for more information at this point, but a long form is always a turn-off. Here is the registration form: So, we have text fields for name, email and the password.
Note that we are using the password widget for better usability.
At this point it is a good idea to put some form validation code in place, so we make sure that we have all the data required to create the user account.
We need to check if name and email, and password are filled in and that the email is in the proper format.
After logging in, we make sure that the table is existing.(If not, the script will create the required table).
Then we make sure that the username and email are unique.
Creating a membership based site seems like a daunting task at first.
Note that we make the confirmation URL point to confirmreg.php? In the script, we search for this confirmation code and update the ‘confirmed’ field in the table.Now that we have the registration in our database, we will send a confirmation email to the user.The user has to click a link in the confirmation email to complete the registration process.Please note that because MD5 is an one-way encryption method, we won’t be able to recover the password in case the user forgets it.Here is the code that we use to insert data into the database.