I have the following form and php script:
<form method="post" action="index.php">
<h1>Contact</h1>
<label>Name</label>
<input name="name" placeholder="Type Here">
<label>Email</label>
<input name="email" type="email" placeholder="Type Here">
<label>Message</label>
<textarea name="message" placeholder="Type Here"></textarea>
<input id="submit" class="button" name="submit" type="submit" value="Submit">
</form>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'SJW&T Contact Form';
$to = '[email protected]';
$subject = 'Hello';
$human = $_POST['human'];
$body = "From: $name\n E-Mail: $email\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>
But my web host seems to be returning an error 404. I tried the suggestion in this thread, which is a near duplicate, but it did not work. Anyone see any syntax errors? My web host is 000webhost.com. It doesn't give me an actual 404 message, but the URL it takes me to is error404.000webhost.com.
index.phpinstead ofindex.html. That way youractionis valid and the php will be processed.ifstatement and useisset()orempty()to get rid of the warnings.htmlextension, the web server will not parse any PHP, as it interprets the page as an HTML file. Changing the extension tophpwill tell the web server "hey, I'm a PHP file. Parse anything between<?phpand?>as PHP".