dimanche 29 mars 2015

.php simple contact form won't send email

I have created a very simple HTML form, and created a PHP form verbatim from a tutorial, changing only that which I needed to change to match my HTML form. I am getting no error messages, but the form never sends the email. I have posted the two codes below:


HTML



<form action="general.php" method="post" name="genform">
<label class="contact" for="pronom">First Name:</label>
<input type="text" name="pronom" autofocus required>
<label class="contact" for="surname">Last Name:</label>
<input type="text" name="surname" required><br><br>
<label class="contact" for="email">Email:</label>
<input type="email" name="email" required>
<label class="contact" for="date">Date:</label>
<input type="date" name="date"><br><br>
<label class="contact" for="text">Question/Concern:</label>
<textarea name="text" rows="6" cols="50" required></textarea><br><br>
<input type="submit" name="send" value="Send Message">
</form>


PHP



<?php
if (isset($_POST['send'])) {
$to = 'me@mymail.org'; //*Changed this, obviously, as well as below
$subject = "New message from $name";
$message = "First Name: " . $_POST['pronom'] . "\r\n\r\n";
$message .= "Last Name: " . $_POST['surname'] . "\r\n\r\n";
$message .= "Email: " . $_POST['email'] . "\r\n\r\n";
$message .= "Date: " . $_POST['date'] . "\r\n\r\n";
$message .= "Message: " . $_POST['text'];
$message = wordwrap($text, 70);
$headers = "From: webmaster@pittcountyaoh.org\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8';
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
if ($email) {
$headers .= "\r\nReply-To: $email";
}
$success = mail($to, $subject, $message, $headers, '-fme@mymail.org');
}
?>
<?php if (isset($success) && $success) { ?>
<h1>Thank you!</h1>
<p3>Your message has been sent, and someone will get back to you shortly.</p3>
<?php } else { ?>
<h1>Oops!</h1>
<p3>There was a problem sending your message.</p3>
<?php } ?>


I have tested the mail function with a very simple test php, and it worked. I have checked spam and everything else. Can someone please offer some advice?


Aucun commentaire:

Enregistrer un commentaire