I have the form inserting the data into the Db sucessfully but now I want to receive the results by e-mail too. I know that the form cannot have two actions so where might I set the results to be mailed to me?
Thanks
<?php
if (!isset($_POST['submit'])) {
// form not submitted
?>
<form action="<?=$_SERVER['../PHP_SELF']?>" method="post">
<p> Customer Name: <input type="text" name="customer_name"></p>
<p> Address: <input type="text" name="customer_address"></p>
<p> Province: <input type="text" name="customer_province"> </p>
<p> Phone Number: <input type="text" name="customer_phone"> </p>
<input name="submit" type="submit" value="Submit">
<!-- "<a href="mailto:tom@cedarsprings.cc">tom@cedarsprings.cc</a>"; -->
</form>
<?php
}
else {
// form submitted
// set server access variables
$host = "localhost";
$user = "llgg_tom";
$pass = "tom";
$db = "llgg_info";
// get form input
// check to make sure it's all there
// escape input values for greater safety
$customer_name = empty($_POST['customer_name']) ? die ("ERROR: Enter your name") : mysql_escape_string($_POST['customer_name']);
$customer_address = empty($_POST['customer_address']) ? die ("ERROR: Enter address") : mysql_escape_string($_POST['customer_address']);
$customer_province = empty($_POST['customer_province']) ? die ("ERROR: Enter your province") : mysql_escape_string($_POST['customer_province']);
$customer_phone = empty($_POST['customer_phone']) ? die ("ERROR: Enter your phone number") : mysql_escape_string($_POST['customer_phone']);
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
// create query
$query = "INSERT INTO user (customer_name, customer_address, customer_province, customer_phone) VALUES ('$customer_name', '$customer_address', '$customer_province', '$customer_phone')";
// execute query
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
// print message with ID of inserted record
echo "New record inserted with ID ".mysql_insert_id();
// close connection
mysql_close($connection);
echo "<a href=\"1r.php\">Click to add more</a>";
}
?>