Hi guys,
I've seen this type of question many many times but I can't seem to figure it out for my own.
I have a form that inserts records into a database. This works fine. I want to add a check to prevent duplicate emails and if there's a duplicate email it goes to 1 page, and if its unique then it goes to another page.
I want to learn so if someone could please point me in the right direction that would be great. I saw code similar to SELECT etc but I just dont know where to put it
Here's my code from the w3schools tutorial:
<?php
$con = mysql_connect("localhost","****","****");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("****", $con);
$sql="INSERT INTO customers (FirstName, LastName, Email, Address, City, State, ZipCode)
VALUES
('$_POST[FirstName]','$_POST[LastName]','$_POST[Email]','$_POST[Address]','$_POST[City]','$_POST[State]','$_POST[ZipCode]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>