Save phpencryption.php as sqlencryption.php.  Delete the line which encrypts $firstvalue.  Add a database connection (two lines) to intsql.  Save this exported sql and import it into intsql using PHPMyAdmin.  Note that the encrypted data will be stored in a varbinary field which is not essential but is recommended.

Replace the query and the following echo line with this (ignore the mysalt bit that will be explained soon):

$query="INSERT INTO `encryption` (`firstvalue`, `encryptedFirstValue`) VALUES ('$firstvalue', AES_ENCRYPT('$firstvalue', 'mysalt'));";
mysqli_query($dbconnection, $query) or die(mysqli_error($dbconnection));

First the query is put into a variable and then it is sent to the server.  You have been doing this in one line of code but this way can be easier when queries get complicated.  Try typing a few things into the form and submitting it.  Check in PHPMyAdmin and you should see the text before and after encryption.


Place this code just below the two lines which run the current query:

$selectQuery="SELECT `firstvalue`, `encryptedFirstValue`, AES_DECRYPT(`encryptedFirstValue`, 'mysalt') AS decryptedText FROM `encryption`;";
$selectResult=mysqli_query($dbconnection, $selectQuery) or die(mysqli_error($dbconnection));
echo "<ul>";
while ($selectRow=mysqli_fetch_array($selectResult)){

    echo "<li>$firstvalue becomes-> $encryptedFirstValue becomes-> $decryptedText</li>";
echo "</ul>";

Now when you load the page you should see the records from the database including the encrypted and decrypted text.