Results 1 to 2 of 2

Thread: Newsletter Form

  1. #1

    Thread Starter
    Hyperactive Member Olly79's Avatar
    Join Date
    May 2005
    Posts
    264

    Newsletter Form

    Hi all,

    Just wondering if someone could assist me with the following issue. I have a web form which simply consists of the folowing:

    HTML Code:
    <form action="" class="newsletter">
    <strong>Enter your email</strong><br />
    to receive our latest news and proposals
    <div>
    <inout type="text" value="" /><a href="#"><img alt"" src="images/button_sign_up.gif" /></a>
    </div>
    </form>
    What I wanted to do was send the submitted form to an email address and a database.

    I cobbled the following together for the database:

    PHP Code:
    function add_to_db($data){
        
    $link mysql_connect("localhost""username""password") or die("Could not connect: " mysql_error());
        
    mysql_select_db("dbname"$link) or die ('Can\'t use this DB : ' mysql_error());
        
    $values '';
        
    $flds '';
        foreach (
    $data as $f => $val){
            
    $values .= (empty($values) ? "'".$val."'" ",'".$val."'");
            
    $flds .= (empty($flds) ? $f ','.$f);
        }

        
    $sql "INSERT INTO contact ({$flds}) VALUES({$values})";
        
    $result mysql_query($sql) or die("Invalid query: " mysql_error());
        
    mysql_close($link);

    However, I'm not sure of where or how to add the email function for this so it send the submitted form to an email account as well as the database.

    Any help much appreciated.

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Newsletter Form

    just call your add_to_db() function in conjunction with a call to mail() to send the email.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width