Forum Moderators: coopster

Message Too Old, No Replies

Auto response emails

         

onoff

2:40 pm on Aug 25, 2005 (gmt 0)

10+ Year Member



Hi,

I have set a form which simply inputs data in a database, however I am wondering how to send an email automatically notifing the database administrator every time someone signs up with the form.

Cheers

jatar_k

2:52 pm on Aug 25, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



you could take the same inserted information and put it together and send it using the mail function [php.net]

henry0

3:02 pm on Aug 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi onoff,
the following is pretty rough
but you'll get the idea :)

add it at the end of your DB update/insert script

and also verify that the form cannot be sent twice.

<?
// ### email to user

$conn = db_connect(); // your DB conn function
$sql= "select contact_email from TABLE where id=$new_content";
// I suppose that you grab the user's email and feed your DB with.
$result = mysql_query($sql,$conn);
while ($new_content=mysql_fetch_array($result) )
{
$contact_email= $new_content[contact_email]; //echo "$contact_email";
}

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$email=$_POST['email'];
$to=$email;

$subject="New member";

$message="Dear Site Administrator <br> New member aaaaaaaaaaaaaaaaaaa ";

if (@mail($to, $subject, $message, $headers)) {
echo('<h3><b>Whatever.......</h3>');

} else
{
echo('<p>Hmmm! Slight email problem...</p>');
}
// ## end of email

?>