My problem is I cannot figure out how to check to see if a record is already in the database. This is the table stucture,
author_id pk auto_increment
au_Fn varchar(35)
au_Ln varchar(2)
au_Mn varchar(35)
here the code I'm using right now,
$hostname = "localhost";
$database = "mm";
$username = "root";
$password = "";
$mormon_memorabilla = mysql_pconnect($hostname, $username, $password) or trigger_error(mysql_error("You connected sucessfully"),E_USER_ERROR);
mysql_select_db($database, $mm);
$result = mysql_query('SELECT au_Fn, au_Mn, au_Ln FROM authors WHERE au_Fn, au_Mn, au_Ln LIKE "'.$POST['au_Fn'].'", "'.$POST['au_Mn'].'", "'.$POST['au_Ln'].'"');
if (mysql_num_rows($result))
{
echo "Sorry! It already exists. Try again";
}
else
{
if(isset($POST ['Submit']))
{
echo "Inserting Name into the database<br>";
// First Insert
$query = "INSERT INTO authors VALUES ( NULL, '$POST[au_Fn]', '$POST[au_Mn]', '$POST[au_Ln]')";
mysql_query($query, $mm;
if ( (!empty($POST['tau_Fn'])) && (!empty($POST['tau_Mn'])) && (!empty($POST['tau_Ln'])) )
{
$query = "INSERT INTO authors VALUES ( NULL, '$POST[tau_Fn]', '$POST[tau_Mn]', '$_POST[tau_Ln]')";
mysql_query($query, $mm);
}
}
}
//if (!isset(mysql_query($sql, $mm))
// {
// }
?>