I'm brand new to
PHP. I created an email / contact form (still testing on my localhost), but when I hit submit it doesn't send the email and doesn't redirect to my custom thank you page. I don't get an error; instead, the browser just keeps spinning as if it's trying to connect to something.
I took the
PHP code from a tutorial (but it didn't show how to redirect to a thank you page, so I added that part from another tutorial). Any idea what I'm missing?
Thank you! - Kurt
The
PHP:
- Code: Select all
<?php
if($_POST['action'] == "send"){
$message = "";
$message .= "User has filled in the Mail form at " . date("H:i") . " on " . date("m/d/Y") . "\n\n";
$message .= "Name: " . $_POST['name'] . "\n";
$message .= "Email: " . $_POST['email'] . "\n";
$message .= "Subject: " . $_POST['subject'] . "\n";
$message .= "Message: " . $_POST['message'] . "\n";
$to = "tears@oldmencrying.com";
$subject = "User has filled in the Mail Form";
$headers = "From: Mail Form <mailform@oldmencrying.com>\r \n";
$headers .= "X-Priority: 1 \r \n";
$headers .= "X-MSMail-Priority: High";
// Send email and direct browser to confirmation page
mail($to,$subject,$message,$headers);
header( "Location: http://www.oldmencrying.com/thankyou.html" );
}
?>
The
HTML:
- Code: Select all
<div id = "contactform">
<form action="contact.php" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Personal information</legend>
<label for="name">Name</label>
<input name="name" id="name" type="text" size="50" maxlength="50" />
<label for="email">E-mail</label>
<input name="email" id="email" type="text" size="50" maxlength="50" />
<legend>Message</legend>
<label for="subject">Subject</label>
<input name="subject" id="subject" type="text" size="50" maxlength="50" />
<label for="message">Message</label>
<textarea name="message" cols="50" rows=7" id="message"></textarea>
<input class="button" type="submit" name="send" value="Send message" />
<input type="hidden" name="action" value="send" />
</fieldset>
</form>
</div>