Forum Moderators: coopster
I need to replace a printf with some sort of e-mail function after a script has successfully been completed, but I'm not sure how to do that. Any help would be greatly appreciated.
Here's the code
<?
// Set a variable with the database name
$database_name = "MYDB";
// Attempt to connect to database and store result
$dbh = mysql_connect("localhost","username","password");
// Check the result of the connection attempt
if (!mysql_select_db($database_name)) {
echo "Can't Select $database_name";
}
// Conditional test to see if submit button was pressed
if ($enter_data) {
// Build our query string
$sql = "insert into users (fname, lname, yborn, gender, email) values
('$fname', '$lname', '$yborn', '$gender', '$email')";
// Execute a query and store the result
$res = mysql_query($sql,$dbh);
// Check to make sure the query actually ran
if (!$res) {
echo mysql_errno().": ". mysql_error ()."";
return 0;
}
printf("<p>Record successfully added</p>");
}
?>
Thanks!
mail("you@example.com","your subject", "your message"); or using variables:
mail($to_address,$subject, $message);