chilipie
03-20-2007, 05:13 PM
I have an email form from way back, but in editing it I've somehow managed to break it. Here's what I've got:
<?php
if(isset($contact))
{
if(!empty($_POST['name']) and !empty($_POST['email']) and !empty($_POST['subject']) and !empty($_POST['message']))
{
mail("ollie@chilipie.co.uk", "BM Contact Form: ".$_POST['subject'], $_POST['message'], "From: ".$_POST['name']." <".$_POST['email'].">\r\n") or die("Sorry, but the form isn't working at the moment. Please try again later.");
header("refresh: 0; url=contact.php?form=done");
} else {
die(header("refresh: 0; url=contact.php?form=error"));
}
}
?>
And then below it, in the body of the page:
<?php
if($_GET['form'] == 'done')
{
echo "<p>Thank you, your message has been sent successfully. We will endeavour to reply as soon as possible.</p>";
}
if($_GET['form'] == 'error')
{
echo "<p>Uh-oh! Please check that all fields in the form were filled in and try again.</p>";
}
?>
<form action="contact.php" method="post">
<label for="form-name">Name</label>
<input type="text" name="name" id="form-name" size="30" />
<label for="form-email">Email</label>
<input type="text" name="email" id="form-email" size="30" />
<label for="form-subject">Subject</label>
<input type="text" name="subject" id="form-subject" size="30" />
<label for="form-message">Message</label>
<textarea name="message" id="form-message" cols="60" rows="10"></textarea>
<input type="submit" name="contact" />
</form>
I'm not getting returned any errors - it just doesn't seem to do anything apart from load contact.php again. It's probably something ridiculously easy to fix, but I'm just lost because of the lack of any error messages.
Thanks
Ollie
<?php
if(isset($contact))
{
if(!empty($_POST['name']) and !empty($_POST['email']) and !empty($_POST['subject']) and !empty($_POST['message']))
{
mail("ollie@chilipie.co.uk", "BM Contact Form: ".$_POST['subject'], $_POST['message'], "From: ".$_POST['name']." <".$_POST['email'].">\r\n") or die("Sorry, but the form isn't working at the moment. Please try again later.");
header("refresh: 0; url=contact.php?form=done");
} else {
die(header("refresh: 0; url=contact.php?form=error"));
}
}
?>
And then below it, in the body of the page:
<?php
if($_GET['form'] == 'done')
{
echo "<p>Thank you, your message has been sent successfully. We will endeavour to reply as soon as possible.</p>";
}
if($_GET['form'] == 'error')
{
echo "<p>Uh-oh! Please check that all fields in the form were filled in and try again.</p>";
}
?>
<form action="contact.php" method="post">
<label for="form-name">Name</label>
<input type="text" name="name" id="form-name" size="30" />
<label for="form-email">Email</label>
<input type="text" name="email" id="form-email" size="30" />
<label for="form-subject">Subject</label>
<input type="text" name="subject" id="form-subject" size="30" />
<label for="form-message">Message</label>
<textarea name="message" id="form-message" cols="60" rows="10"></textarea>
<input type="submit" name="contact" />
</form>
I'm not getting returned any errors - it just doesn't seem to do anything apart from load contact.php again. It's probably something ridiculously easy to fix, but I'm just lost because of the lack of any error messages.
Thanks
Ollie