I’ve been working on a website and added a form to make it send me an email but it keeps saying “404 not allowed”
<form action="emailhandler.php" method="post">
Name:<br>
<input type="text" name="name"><br>
Email:<br>
<input type="email" name="email"><br>
Message:<br>
<textarea name="message"></textarea><br><br>
<input type="submit" value="Submit">
</form>
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = '-------------------(email hidden for privacy)';
$subject = 'New message from your website';
$headers = "From: " . $email;
mail($to, $subject, $message, $headers);
echo "Email sent!";
}
?>
New contributor
nat33322 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.