I have a registration form in PhP submitting various entries into a MySQL database.
The code is as:
if($conn)
{
$sql = "INSERT INTO Participants
(ID,
title,
surname,
name,
organization1,
organization2,
address1,
address2,
country,
email,
phone,
type_reg,
abstract,
bm1,
bm2,
bm3,
bm4 )
VALUES
('$auth_id',
'$auth_title',
'$auth_sname',
'$auth_name',
'$auth_org_line1',
'$auth_org_line2',
'$auth_add_line1',
'$auth_add_line2',
'$auth_country',
'$auth_email',
'$auth_phonen',
'$reg_type',
'$new_file_name',
'$bm1',
'$bm2',
'$bm3',
'$bm4' )";
mysql_query($sql);
if( mysql_errno() !== 1062) {
print '<script type="text/javascript">';
print 'alert("Your pre-registration has been submitted successfully. You will receive a confirmation e-mail soon.")';
print '</script>';
print '<script type="text/javascript">';
print 'parent.location.href = "Success.html"';
print '</script>';
mysql_close($conn);
}
else
{
echo 'Data base error. Try later.';
}
Because I am sending confirmation e-mails with cc to me, I am aware of the people registering and when I check the database I find that some of them are not being inserted into the database.
What I'm looking for is for a way to only validate the registration IF the entries were inserted into the MySQL table.
Is there a simple way?
Should I verify if the query was successful? How?
Should I look for the ID on the table and verify if it exists? How? (the entry ID is set as unique)