Try this:
Code:
<?php
if (isset($_POST['submit'])){
$First_Name = $_POST['First_Name']; // getting the value of first name
$Last_Name = $_POST['Last_Name']; // getting the value of last name
$Email = $_POST['Email']; // getting the value of E-mail
$Phone = $_POST['Phone']; // getting the value of Phone number
$Subject = $_POST['Subject']; // getting the value of Subject
$to = "info@charismaticbelieverschurchinternational.com";
$message = "From : $First_Name $Last_Name\n";
$message .= "Phone : $Phone\n";
$message .= $_POST['Message'];
$from = $Email;
if ( mail($to, $Subject, $message, $from) ) { // This line is the key to sending an email. Without it, no email will ever be sent
echo "<p>Your message has been delivered successfully. Thank you.</p>";
} else {
echo "<p>There was a problem.</p>";
}
}
?>
I got rid of your $error_occurred variable because it is not doing anything in your script.
I would recommend validating all of the information your users are providing in the form too. Especially the email address. You could use the code below to check if the user provided a valid email address.
Code:
if ( preg_match('/^[A-Za-z0-9](([_\.\-]?[a-zA-Z0-9]+)*)@([A-Za-z0-9]+)(([\.\-]?[a-zA-Z0-9]+)*)\.([A-Za-z]{2,})$/', $_POST['Email']) ) {
$from = $_POST['Email'];
} else {
echo '<p class="error">Please provide a valid email address.</p>';
}
Good luck!
Jason
Bookmarks