I have been working on how to have my contact page email me after it submits info to my data base. This is the only way I could get it to work at all is this good syntax or should I write it a different way. I had to close out what went to the data base and open another php area to get it to stop throwing an error. All help appreciated.
<html>
<head>
<title>Processing form</title>
<style>
h1 {color:#000080; font-size:35px}
</style>
</head>
<?php
$con = mysql_connect("localhost","######","#######");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$sql="INSERT INTO contact (id, first_name, last_name, address, city, state, zip, area, exchange, phone, email, contact, services, comments)
VALUES
('$_POST[id]','$_POST[first_name]','$_POST[last_name]','$_POST[address]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[area]','$_POST[exchange]','$_POST[phone]','$_POST[email]','$_POST[contact]','$_POST[services]','$_POST[comments]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>
<?php
$to = "harts@hartsmachineservice.com";
$subject = "Contact Page";
$message = "John: Some one has filled and submitted your contact page";
$from = "harts@hartsmachineservice.com";
$headers = "From: $from";
mail($to,$subject,$message,$headers);
echo "Mail Sent ";
?>
<h1>Your information has been successfully submitted to Hart's Machine Service.<br />
We will contact you as soon as possible.</h1>
</body>
</html>