NYCPHP Meetup

NYPHP.org

[nycphp-talk] PHP Mail function code

Steven W. Riedy swr1 at rcn.com
Sat Jul 24 18:49:40 EDT 2004


Hello,

Below is some code that writes input from a form to a MySQL DB.  It was running fine until I added the email function seen at the end.  Now this does not write to the DB, but the email is getting sent.  Any ideas why?

Thanks
Steve
(Newbie)

<?php

$host = 'localhost';

$user = 'xxxxxxx';

$pass = 'xxxxxxx';

$myDB = 'candles';

$connect = mysql_connect($host, $user, $pass);

 

//insert string for first table

 

$today = date('M d Y');

$table_name = 'logon';

 

//create query string to insert data into table

 

$query = "INSERT INTO $table_name (today, fname, lname, address, city, state, zip, email, password, passCheck, passQuestion, passAnswer) VALUES ('$today', '$fname', '$lname',

'$address', '$city', '$state', '$zip', '$email', '$password', '$passCheck', '$passQuestion', '$passAnswer')";

?>





(I left out all the print statements where it was printing the info back to the form)

--------------------------

<?php

                                    //Print statement to verify if connection and inserts were made

 

                                    mysql_select_db($myDB);

                                    if (mysql_query($query, $connect)){

                                    print "Your logon request registration was successful on $today!  Your password and logon info will be emailed to you shortly";

                                    } else {

                                    print "Your brochure request failed to register!";

                                    } mysql_close ($connect);

                                    ?>

                                    </font>

                                    

<?php

                                    

//Send email to registrant advising of userid and password

                                    $body = "Registration complete: Password=$password Userid=$email Answer to Question:$passAnswer";

            $from = 'candleman at rcn.com';

                                    $subject = "Logon info for $fname $lname";

                                    mail($email, $subject, $body, "From: $from");

                                    ?>     
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20040724/77aa0e48/attachment.html>


More information about the talk mailing list