Right now this form gets submited to my database, i want to change it so it is simply emailed to me instead. Can someone please show me how?
<?php
/* -------------------------------------------------------------------
Script written by Adam Khoury @ www.developphp.com
January 1, 2010
Please retain this credit when displaying this code online
---------------------------------------------------------------------- */
$name = "";
$email = "";
$msg_to_user = "Sign up to receive updates, tips and read stories";
if ($_POST['name'] != "") {
include_once "connect_to_mysql.php";
// Be sure to filter this data to deter SQL injection, filter before querying database
$name = $_POST['name'];
$email = $_POST['email'];
$sql = mysql_query("SELECT * FROM righthands WHERE email='$email'");
$numRows = mysql_num_rows($sql);
if (!$email) {
$msg_to_user = '<font color="FF0000">Please type an email address ' . $name . '.</font>';
} else if ($numRows > 0) {
$msg_to_user = '<font color="FF0000">' . $email . ' is already in the system.</font>';
} else {
$sql_insert = mysql_query("INSERT INTO righthands (name, email, dateTime)
VALUES('$name','$email',now() )") or die (mysql_error());
$msg_to_user = '<font color="0066FF">Thanks ' . $name . ', you have been added successfully.</font>';
$name = "";
$email = "";
}
}
?>
<html>
<head>
</head>
<body>
<form style="width:740px;" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<?php echo $msg_to_user; ?><br>
Name:
<input name="name" type="text" maxlength="36" value="<?php echo $name; ?>" />
Email:
<input name="email" type="text" maxlength="36" value="<?php echo $email; ?>" />
<input name="mySubmitBtn" type="submit" value="Submit">
</form>
</body>
</html>