Hello! I am very new to the world of web development. Especially php. I tried to create a contact form using mail(). Everything looks as though it’s correct, the forms look good and I’m receiving my thank you page after I submit, but I am not actually receiving any emails from it. Can anyone one help. I’ve been looking at this far too many hours.
Here’s my .php
<?php $myemail = "[email protected]" ; $subject = "Self-Defense Message"; $name = check_input($_POST['name']); $phone = check_input($_POST['phone']); $email = check_input($_POST['email']); $message = check_input($_POST['message']); if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("Email address not valid"); } $message = " Subject: $subject Name: $name Phone: $phone Email: $email Message: $message "; mail($myemail, $subject, $message); header('Location: thankyou.html'); function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html>
<body>
<p>Please correct the following error:</p>
<strong><?php echo $myError; ?></strong>
<p>Hit the back button and try again</p>
</body>
</html>
<?php
exit();
}
?>