I can't seem to work out how to check if an email exists in my database. Currently users use their email address to login to my site with a password but currently a user can register more than once with the same email address which is cause big issues on my site. Have done some research but can't seem to work it out.
Can anybody help me?
<?php
if(isset($_POST['add']))
{
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'pass';
$db = "db";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not send your enquiry at this time please try again later.');
}
$phone = mysql_real_escape_string((string)$_POST['phone']);
$email = mysql_real_escape_string((string)$_POST['email']);
$password = mysql_real_escape_string((string)$_POST['password']);
$firstname = mysql_real_escape_string((string)$_POST['firstname']);
$surname = mysql_real_escape_string((string)$_POST['surname']);
$country = mysql_real_escape_string((string)$_POST['country']);
$nationality = mysql_real_escape_string((string)$_POST['nationality']);
$yearofbirth = mysql_real_escape_string((string)$_POST['yearofbirth']);
$profession = mysql_real_escape_string((string)$_POST['profession']);
$status = mysql_real_escape_string((string)$_POST['status']);
$membertype = 'Registered';
$dateregistered = mysql_real_escape_string((string)$_POST['dateregistered']);
$agreedtoterms = mysql_real_escape_string((string)$_POST['agreedtoterms']);
$sql = "INSERT INTO members
(phone, email, password, firstname, surname, country, nationality, yearofbirth, profession, uniquepin, status, membertype, dateregistered, agreedtoterms)
VALUES('$phone', '$email', '$password', '$firstname','$surname','$country','$nationality','$yearofbirth','$profession','$uniquepin','$status','$membertype','$dateregistered', '$agreedtoterms')";
mysql_select_db($db);
$retval = mysql_query( $sql, $conn )or die(mysql_error());
?>