I have a contact form on my website and I get the "Cannot POST /contact.php" error.
This is my form at html page:
<form role="form" action="contact.php" method="post">
<div class="form-group">
<label for="InputName">Nom</label>
<div class="input-group">
<input type="text" class="form-control" name="name" id="InputName" placeholder="Nom" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span>
</div>
</div>
<div class="form-group">
<label for="InputEmail">Email</label>
<div class="input-group">
<input type="email" class="form-control" id="InputEmail" name="email" placeholder="Email" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span>
</div>
</div>
<div class="form-group">
<label for="InputEmail">Sujet</label>
<div class="input-group">
<input type="text" class="form-control" id="InputEmail" name="subject" placeholder="Sujet" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span>
</div>
</div>
<div class="form-group">
<label for="InputMessage">Message</label>
<div class="input-group">
<textarea name="message" id="InputMessage" class="form-control" rows="5" required></textarea>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span>
</div>
</div>
<div class="form-group">
<label for="InputReal">5 + 10? (Spam Checker)</label>
<div class="input-group">
<input type="text" name="human" class="form-control" name="InputReal" id="InputReal" required>
<span class="input-group-addon"><i class="glyphicon glyphicon-ok form-control-feedback"></i></span>
</div>
</div>
<input type="submit" name="submit" id="submit" value="Submit" class="btn btn-info pull-left">
</form>
And then I tried my PHP code (contact.php). I don't know if there is something wrong as I am very bad at PHP:
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$to = '[email protected]';
$subject = $_POST['subject'];
$human = $_POST['human'];
$body = "From: $name
E-Mail: $email
Message:
$message";
if ($_POST['submit'] && $human == '15') {
if (mail($to, $subject, $body)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
} else if ($_POST['submit'] && $human != '15') {
echo '<p>You answered the anti-spam question incorrectly!</p>';
}
?>
If anyone who understands PHP could help, that would be amazing.
Thanks in advance.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…