0xfo7d
קוד:
mysql_query("INSERT INTO `emails` SET
`email_address`='".$_POST["email_address"]."'
");
echo mysql_error();
if(mysql_affected_rows() > 0) {
echo "<font color='red'>האימייל נוסף בהצלחה</font>";
echo "<META HTTP-EQUIV=Refresh CONTENT='1; URL=?action=mail_manager&sa=edit'>";
} else {
echo "<font color='red'>שגיאה בעת תהליך הוספת האימייל</font>";
}
הדרך שבה אתה בודק היתה יכולה להיות נכונה רק אם היית מגדיר את email_address כ UNIQUE KEY במוסד הנתונים
ou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
תבדוק עכשיו
קוד:
$email = $_POST['email_address'];
$result = mysql_query("SELECT * FROM `emails` WHERE `email_address`= '$email' ") or die(mysql_error());
$search = mysql_num_rows($result);
if ($search == 0)
{
mysql_query("INSERT INTO `emails` (`email_address`) VALUES ('$email')") or die(mysql_error());
echo("<font color=\"red\">האימייל נוסף בהצלחה</font>");
}
else {
echo("<font color=\"red\">אנא בחר אימייל אחר</font>");
}