You are here: Re: another pointer Thanks ind ADV « PHP SQL « IT news, forums, messages
Re: another pointer Thanks ind ADV

Posted by Scott Johnson on 10/05/87 11:32

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'] ;
> $sql = "INSERT INTO `contest` (`id`, `email`, `link`) VALUES ('',
> '$email2', '$site')";
> $link = mysql_query($sql,$cn);
> ?>
> <link rel="stylesheet" type="text/css" href="style.css">
> <table border=0 cellspacing=0 cellpadding=5>
> <tr>
> <td width=250 bgcolor=#999999></td>
> <td width=500 bgcolor=#EFEFEF>
> <?php
> // multiple recipients
> $to = $_POST['email'] . ', webmaster@XXXXXXXXXXX.com'. "\r\n"; // note
> the comma
> // subject
> $subject = 'Contest Entry From '. $_POST['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";
>
> // Additional headers
> $headers .= 'To: ' . "\r\n";
> $headers .= 'From: XXXXXXXXXXX.com <webmaster@XXXXXXXXXXXXXX.com>' . "\r
> \n";
>
> // Mail it
> mail($to, $subject, $message, $headers);
> ?>
> <h2>Thanks!</h2>
> Email has been sent to <?php echo $_POST['email']; ?>!
> </td>
> <td width=250 bgcolor=#999999></td>
> </tr>
> </table>
>
>
>
Im a bit confused. The code you sent does not have any 'searching' in
it. Did you include the code that you tried to search with, or did you
want someone to make the code for you?

The basic logic however would be a few if() statements.

<?php
Perform your query for both site AND email then see if any rows are
returned.

if(rows are returned){
Tell user they already exist.
}else{
Insert new data and send mail.
}
?>

 

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

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