I am unsure if my prepare statement is working correctly or not.
When I fill out my web form, it adds to the database successfully, but is it protected?
<?php
if(isset($_POST['submit']))
{
/* check no input is left empty */
if(!empty($_POST['wifi']) && !empty($_POST['ringer']) && !empty($_POST['lock']))
{
// Prepare a query for execution
$result = pg_prepare($db, "query", 'INSERT INTO preferences VALUES ($1, $2, $3, $4)');
$result = pg_execute($db, "query", array($_GET[imei], $_POST[wifi], $_POST[ringer], $_POST[lock]));
echo '<script language="javascript">';
echo 'alert("Submitted successfully. You may now close this window.")';
echo '</script>';
} else {
echo '<script language="javascript">';
echo 'alert("Please complete the form again, make sure you have filled in all fields.")';
echo '</script>';
}
}
?>
The only text field is wifi
.
I am using PostgreSQL database.
Is this prepare statement working and protecting my database from attacks properly?