Looking to have this do a lookup into the db
Before it does the insert
If $email2 AND $site are in the data base stop tell the user he/she is
already entered.
If does not exisit then do the insert and send the email.
// message
include "common.php";
$sql = "select message from email where id=2";
$link = mysql_query($sql,$cn);
$data = mysql_fetch_row($link);
//echo "$data[0]";
$message = $data[0];
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
Thanks!
Email has been sent to !
Re: can any one help me with this Thanks
am 19.11.2005 13:52:43 von Shion
annie wrote:
> Looking to have this do a lookup into the db
> Before it does the insert
> If $email2 AND $site are in the data base stop tell the user he/she is
> already entered.
> If does not exisit then do the insert and send the email.
>
> I have tried but failed
$check_sql="SELECT id FROM contest WHERE email='$email2' link='$site'";
$result=mysql_query($check_sql);
if(mysql_num_rows($result,$link)) {
/* There are one or more rows with the same email and site */
echo "Sorry, you already sent it \n";
} else {
/* There are 0 such rows that has both email and site */
echo "Add your code for sending the mail \n";
}
?>
//Aho
Re: can any one help me with this Thanks
am 09.01.2006 23:40:46 von Jim Michaels
you forgot the AND. I will insert below (and the rest of the code).
"J.O. Aho" wrote in message
news:3u8lgsFv7i4gU1@individual.net...
> annie wrote:
>> Looking to have this do a lookup into the db
>> Before it does the insert
>> If $email2 AND $site are in the data base stop tell the user he/she is
>> already entered.
>> If does not exisit then do the insert and send the email.
>>
>> I have tried but failed
>
>
>
> include "common.php";
> $email2= $_POST['email'] ;
> $site= $_POST['site'] ;
>
> $check_sql="SELECT id FROM contest WHERE email='$email2' AND
> link='$site'";
> $result=mysql_query($check_sql);
> if(mysql_num_rows($result,$link)) { // There are one or more rows with
> the same email and site
> echo "Sorry, you already sent it \n";
> } else { // There are 0 such rows that has both email and site
$to = $_POST['email'] . ', webmaster@XXXXXXXXXXX.com'. "\r\n"; // note
the comma
// subject
$subject = 'Contest Entry From '. $_POST['email'] ;
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
Email has been sent to $_POST[email]\n";
/* was probably filtered out by yahoo spam filters too */
} else {
echo "mail could not be sent. please hit the refresh button to
try again later. \n"
}
}