nagger2000 Posted February 4, 2009 Share Posted February 4, 2009 Grateful if anyone could help. I am using the following php to submit a form to a database but I also want to have the details of the same form emailed too. Just not sure how to go about it? <?php $con = mysql_connect("XXXXXX.xxx.XXXX", "XXXXXX", "XXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xxxxxxxxx_xxx_xx", $con); $sql="INSERT INTO database table (name, age, email, contact, Schoolorcollege, date, hear) VALUES ('$_POST[name]', '$_POST[age]','$_POST[email]','$_POST[contact]','$_POST[schoolorcollege]','$_POST[date]','$_POST[hear]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<meta http-equiv='Refresh' content='0; URL=http://www.xxxxxxxxxx.com/thankyou.php'>"; mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/143827-php-email-and-submit-to-database/ Share on other sites More sharing options...
sdi126 Posted February 4, 2009 Share Posted February 4, 2009 you want to have a look at the mail function. <?php mail('[email protected]','subject here','body of the message here...put your $_POST variables');?> Link to comment https://forums.phpfreaks.com/topic/143827-php-email-and-submit-to-database/#findComment-754653 Share on other sites More sharing options...
nagger2000 Posted February 4, 2009 Author Share Posted February 4, 2009 Thanks, But can the mail function be incorporated into the existing script so that submission to the database and an email are processed at the same time? Link to comment https://forums.phpfreaks.com/topic/143827-php-email-and-submit-to-database/#findComment-754686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.