HTML form inserting user entered data to database and validating if userid is already exist.

preview_player
Показать описание
In part 1 we already discussed about how to validate user input and show any validation failure message to user if the validation fails.

In part 3 we discussed how to validate login details with MySQL table and create session.

We will start from after the clearance of validation of inputs. Now all the validations are passed and the data is available for processing.
Connection to Database.
We will create the Database connection string in PHP.
We will create one PDO connection object by entering userid and password and address of mysql database.
After connecting this string we will have the connection object and this object we will use.
MySQL will return as one unique id or membership id for the auto increment mem_id column and the same can collected by using lastInsertId() function. Once we get the lastInsertId() number from the database, this will confirm that the data is inserted to table.
We have used else part of the sql-execute() to generate and display error message if any returned by MySQL database.
Once the data is stored inside MySQL database , we can add one more validation to check if userid is already exists in the membership table. If the userid is already there then we will ask use to use one more userid,
Storing password,
Passwords are stored after using md5 encryption, this is not a very good encryption standard but enough for learning the process. The same method can be modified to include higher end encryption.

HTML of all input fields

Download source code as Zip file from

#phpinsertdata #phpinputtomysql #phpdatastoring #signupdatetomysql #lastinsertid #useridvalidation #mysqlerror #plus2net
Рекомендации по теме
visit shbcf.ru