[thelist] php add email to a mysql db

Gary Bland Gary at star-chaser.com
Mon Aug 12 18:24:01 CDT 2002


Andrew Maynes wrote:
> Hi all
>
> glad we are back online, is it just me or is everyoner getting 2-3 mails of the
> same post?
>
> anyway here is the question, I have a form that I would like to get the email
> inserted into a MySQL db is this possible?  I mean possible to use the existing
> form elements and adding a tick box sent me a weekly newsletter?
>
> Thank you
>
> Andrew
> ---

Yes but you really need to check to see if the email address is already
there so you don't end up with someone putting the same email address in
several times. Here is one Of mine just adjust the INSERT to fit your need.

$sql = "SELECT email FROM TableName WHERE
          email='$email'";
         $result=mysql_query($sql);
         $num=mysql_numrows($result);
         if ($num > 0)
             echo "<center><h3>You are already in our system</h3>";
        else {

$sql = "INSERT INTO TableName(name,email,phone,company,message) VALUES
('$name','$email','$phone','$company','$message')";



--
Gary Bland
StarChaser Web Architecture
http://star-chaser.com
Building Tomorrow's World Today




More information about the thelist mailing list