[thelist] php add email to a mysql db

Andrew Maynes andrew at uk-webdeveloper.co.uk
Tue Aug 13 07:45:01 CDT 2002


this is really useful too, however it is kicking out this

Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource

any ideas?

Thank you

Andrew



-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Gary Bland
Sent: Tuesday, August 13, 2002 12:23
To: thelist at lists.evolt.org
Subject: Re: [thelist] php add email to a mysql db


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

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02




More information about the thelist mailing list