slanderman Posted October 19, 2009 Share Posted October 19, 2009 need some help. I've got a webform that emails form data to me when the user clicks submit. I'm also wanting to store this form data in a database. I've done a little research on the web and the best suggestion ive seen so far suggests to call the database php app from the webform and have the database app invoke formmail to email the data after storing it in the database. The code below is what i'm working with to store the data in the database, but I'm not sure how to make the code invoke the other php app when its done with the database procedures. The other php app is called formmail.php If anyone could please help me I'd really appreciate it. <?php $con = mysql_connect("xxx.xxx.xxx.xxx","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="INSERT INTO tablename (firstname, lastname, email, performername1, performername2) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[performername1]','$_POST[performername2]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con) ?> Link to comment https://forums.phpfreaks.com/topic/178251-insert-into-database-then-invoke-formmailphp/ Share on other sites More sharing options...
MatthewJ Posted October 19, 2009 Share Posted October 19, 2009 You could send mail after inserting as simply as <?php $con = mysql_connect("xxx.xxx.xxx.xxx","username","password"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); $sql="INSERT INTO tablename (firstname, lastname, email, performername1, performername2) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[email]','$_POST[performername1]','$_POST[performername2]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } $message = "Combine your data fields"; mail('youremail', 'subject of email', $message); mysql_close($con) ?> If you want to use formmail.php, just put your code in to insert to the database right above the mail() line in formmail.php Link to comment https://forums.phpfreaks.com/topic/178251-insert-into-database-then-invoke-formmailphp/#findComment-939870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.