You are here: Re: can any one help me with this Thanks « PHP SQL « IT news, forums, messages
Re: can any one help me with this Thanks

Posted by Jim Michaels on 01/10/06 00:40

you forgot the AND. I will insert below (and the rest of the code).
"J.O. Aho" <user@example.net> 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
>
>
> <?PHP
> 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<br>\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'] ;

// message
$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";

// Additional headers
$headers .= 'To: ' . "\r\n";
$headers .= 'From: XXXXXXXXXXX.com <webmaster@XXXXXXXXXXXXXX.com>' . "\r
\n";
// Mail it
if (mail($to, $subject, $message, $headers)) {
$sql = "INSERT INTO `contest` (`id`, `email`, `link`) VALUES
('', '$email2', '$site')";
$link = mysql_query($sql,$cn);
echo "<h2>Thanks!</h2>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.<br>\n"
}
}
</td>
<td width=250 bgcolor=#999999></td>
</tr>
</table>


//Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация