I have an html form, which users will complete and submit. When they hit "submit" I want the form data added to a mySQL database, and I want the data displayed in a web page, with a particular layout, including tables, graphics, etc... This part I've managed so far by having the form "post" to a php page that includes php code to add the data to the database:
Code: Select all
<?PHP
if ($submit == "Submit Assessment")
{
$db = mysql_pconnect("localhost", "xxxx", "yyyy");
if (!$db) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
mysql_select_db("my_database", $db);
$sql = ("INSERT INTO my_table (Cust_Name,Cust_Co,Cust_Email,Cust_Phone,Referral,
Q1,Q2,Q3,Q4,Q5,Q6,Q7,Q8,Q9,Q10,Q11,Q12) VALUES ("$Cust_Name","$Cust_Org","$Cust_Email","$Cust_Phone",
"$Referral","$Q1","$Q2","$Q3","$Q4","$Q5","$Q6","$Q7",
"$Q8","$Q9","$Q10","$Q11","$Q12");");
$result = mysql_query($sql, $db);
}
?>These parts are working fine (if not the most elegant solution). However, I would also like to have the same data, also formatted in html, sent to the submitter in an email.
Is there some snippet of code I can add to this existing page that will do this? Do I need to rework the code completely? Or do I need a separate page?
Any guidance you can offer this newbie is greatly appreciated.
Thanks,
Sinemac