How would I go about changing my submission.php coding so that when someone sends info across to the database, it also sends me an email to let me know?
This is my submission.php file contents presently:
Am I able to just fuck with the code from my feedback form code and append it onto the end of the code in submission.php above?
Any pointers in the right direction would be appreciated
This is my submission.php file contents presently:
<?php
$link = mysqli_connect("localhost", "database", "password", "username");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$title = mysqli_real_escape_string($link, $_REQUEST['title']);
$recipe = mysqli_real_escape_string($link, $_REQUEST['recipe']);
$description = mysqli_real_escape_string($link, $_REQUEST['description']);
$category = mysqli_real_escape_string($link, $_REQUEST['category']);
$name = mysqli_real_escape_string($link, $_REQUEST['name']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);
// Attempt insert query execution
$sql = "INSERT INTO Directory (title, recipe, description, category, name, email) VALUES ('$title', '$recipe', '$description', '$category', '$name', '$email')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>4
$link = mysqli_connect("localhost", "database", "password", "username");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$title = mysqli_real_escape_string($link, $_REQUEST['title']);
$recipe = mysqli_real_escape_string($link, $_REQUEST['recipe']);
$description = mysqli_real_escape_string($link, $_REQUEST['description']);
$category = mysqli_real_escape_string($link, $_REQUEST['category']);
$name = mysqli_real_escape_string($link, $_REQUEST['name']);
$email = mysqli_real_escape_string($link, $_REQUEST['email']);
// Attempt insert query execution
$sql = "INSERT INTO Directory (title, recipe, description, category, name, email) VALUES ('$title', '$recipe', '$description', '$category', '$name', '$email')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>4
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "New Recipe Submission";
}
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "[email protected]";
$email_subject = "New Recipe Submission";
}
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>

Comment