Hi all!
I'm putting a contact form together to receive emails. It is giving the appearance of sending the form data through to my email address (i.e the "thank you" message appears) but nothing is coming through.
I'm not sure if I have incorrect html in my form or if it is a problem with the hosts mail server. No mail server errors are showing though.
I'm wondering if I've given the wrong label values for "for"?
I felt it was better to post this here rather than an html forum.
My script is as below:
/* michael_dev_contact.php */
<h1>Contact Me</h1>
<?php
// Set the default timezone:
date_default_timezone_set('Europe/London');
// Check for form submission:
if(isset($_POST['submitted']))
{
// Minimal form validation:
if(!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['comments']))
{
// Create the body:
$body = "Name: {$_POST['name']}\n\nComments: {$_POST['comments']}";
// Make it no longer than 70 characters long:
$body = wordwrap($body, 70);
// Send the email:
mail('myemail@email.com', 'Contact Form Submission', $body, "From: {$_POST['email']}");
// Print a message:
echo '<p><em>Thank you for contacting me at '.date('g:i a(T)').' on '.date('l F j, Y').
'. I will reply as soon as possible.</em></p>';
// How long did it all take:
/*echo '<p><strong>It took '.(time() - $_POST['start']).' seconds for you to complete
and submit the form.</strong></p>';
*/
// Clear $_POST (so that the form's non-sticky):
$_POST = array();
}
else
{
echo '<p style="font-weight: bold; color: #C00">Please fill out the form completely.</p>';
}
} // End of main isset() IF.
// Create the html form:
?>
<p>Please fill out this form to contact me.</p>
<form action="michael_dev_contact.php" method="post" class="contact">
<div>
<label for="name" class="fixedwidth">Name</label>
<input type="text" name="name" size="30" maxlength="60" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" class="txt"/>
</div>
<div>
<label for="email" class="fixedwidth">Email Address</label>
<input type="text" name="email" size="30" maxlength="80" value="<?php if(isset($_POST['email'])) echo $_POST['email']; ?>" class="txt"/>
</div>
<div>
<label for="comments" class="fixedwidth">Comments</label>
<textarea name="comments" rows="5" cols="30" class="txt"> <?php if(isset($_POST['comments'])) echo $_POST['comments']; ?> </textarea>
</div>
<div class="button">
<input type="submit" name="submit" value="Send!" />
</div>
<input type="hidden" name="start" value="<?php echo time(); ?>" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
Thanks in advance for any help offered.