PHP Data Encryption is important to safety and privacy. In this lesson I am going to show you how to insert and retrieve encrypted data in PHP using a mysql database. Using these methods will make your websites and applications more secure.
PHP DATA ENCRYPTION INSERT RETRIEVE MYSQL DATABASE *
In an earlier PHP Data Encryption lesson I showed you guys how to use Openssl to encrypt and decrypt your data. In this lesson I will show you how to store it and retrieve it from a MySql Database. Here are the files for you to use for the lesson.
Create Database For Encryption *
Create a database to insert your encrypted data. Name the datbase “users” in your phpmyadmin dashboard. Then create a table called people. Next, make 4 columns in the table id, name, email, reg_date. Set the name and email fields to TEXT. Do not use varchar because varchar will only give you 255 charectors and you may need more than that for your encrypted code. We will use this database to insert and retrieve the data.
Create A Config File *
You need to create a config file to connect to your database. This will let us insert our encrypted data and retrieve our encrypted data.
Inserting PHP Encrypted Data *
To insert your PHP Encrypted Data into the database that you created from the information above use this code.
mysqli_query($con,"INSERT INTO people(`name`, `email`)VALUES ('$name','$email')"); echo '<div class="alert alert-success">You entered successfully</div>';
Download all the files here and set them up on your server. Follow the video instructions and if you have any questions feel free to ask them below.
I hope you enjoyed the article. If I was able to help you please consider a tip for the content.
One Time Tip