MySQL Forums
Forum List  »  PHP

help with sending form data to email & mysql at same time
Posted by: john m
Date: July 07, 2008 02:21PM

Hi everyone,
im new here and i was wondering if someone could help me get some code to send form data to an email address and mysql database at the same time. I have the mysql database code and it works fine. Just cant figure out how to add email code to send an email as well. any help is greatly appreciated!

<?php
$con = mysql_connect("localhost","*****","******"); //Replace with your actual MySQL DB Username and Password
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("aston_salesverification", $con); //Replace with your MySQL DB Name
$name=mysql_real_escape_string($_POST['name']); //This value has to be the same as in the HTML form file
$email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file
$sql="INSERT INTO form_data (name,email) VALUES ('$name','$email')"; /*form_data is the name of the MySQL table where the form data will be saved.


name and email are the respective table fields*/
if (!mysql_query($sql,$con)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($con);

?>

Options: ReplyQuote


Subject
Written By
Posted
help with sending form data to email & mysql at same time
July 07, 2008 02:21PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.