I am creating a website about music and at the bottom of my website I have a form that has only email submission. I am doing this in order to gather email from the users.
Moreover, I have created a database and in that database I have created a table called emails with only 2 columns:id
and email
.
I would like to make the emails that I receive unique, because now that I am testing it I can put many emails with the same name. I have tried some coding in order to achieve this but no luck so I will post only the code I have at the moment, so you can help me with what I need to add in that code in order to receive a unique email address.
P.S I will update my database from mysql to mysqli at the end of the project.
Here is my current code:
<?php
error_reporting(E_ERROR | E_PARSE);
include('../database/db.php');
$email = $_POST['email'];
if($email != "") {
$sql = mysql_query ("INSERT INTO emails (email) VALUES ('$email')");
echo "Thank you for Submitting. Redirecting back to Home Page";
}
?>