Please i need your help
i have a problem with avoiding duplicated entries(user name and email)
i can just avoid one of them ,but both i cann't
<?php
// open the connection
$conn = mysql_connect("localhost", "root", "");
// pick the database to use
mysql_select_db("testdb",$conn);
// create the SQL statement
if(trim($_POST[firstname])==''){
die('write your name');
}
elseif (trim($_POST[lastname])==''){
die('write your last name please');
}
$sql = "INSERT INTO reg(firstname,lastname) values ('$_POST[firstname]','$_POST[lastname]')";
mysql_query($sql,$conn);
if(mysql_affected_rows() < 0)
{
print 'This name is already in use!';
}
else
{
echo "thanks for your registration";
echo $_POST['firstname'];
//insert code to insert user here.
}
?>
supose that i want to prevent duplicated email ...and the username at the same time how could i inform the user that the name which is duplicated and not the username and vice versa and not both of them....in addition to that i'm using a unique value in mysql