I'm so sorry guys!
I'm having a very hard time on this.
I saw another code from the internet, tried it out. It's also not sending but it has an error message
array(5) { ["name"]=> string(6) "qwerty" ["email"]=> string(16) "
[email protected]" ["phone"]=> string(7) "1234567" ["message"]=> string(10) "sadfsdasdf" ["submit"]=> string(0) "" }
My new code looks like these:
<?php
var_dump($_POST);
// Check for empty fields
if(empty($_POST['name']) ||
empty($_POST['phone']) ||
empty($_POST['email']))
{
$errors .= "\n Error: all fields are required";
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = '
[email protected]'; // Add your email address inbetween the '' replacing
[email protected] - This is where the form will send a message to.
$subject = "Website Contact Form: $name";
$text = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage:\n$message";
$header = "From:
[email protected]\n"; // This is the email address the generated message will be from. We recommend using something like
[email protected].
mail($to,$subject,$text,$header);
header('Location: thank-you');
?>