Hi,
I've tried creating a form using a template page, then submitting the form to another template page which gets the variables and passes them through mail() as per most contact forms.
This always gave me a 404 error when passing the information onto the page with mail() in, but if no data in the form was passed it would find the page?
I read that WordPress can't handle this form some reason or another, so I'm passing the data to the form data to the same page using <form action"" method="post" > but still get the 404 error. My code works outside of WordPress.
Any ideas people?
Here's my code for my contact template (A shortened version)
<?php
if (array_key_exists('form', $_POST)) {
$name = $_POST['name'];
if (empty($name)) {
echo "You forgot to enter your name";
$process = false;
} else {
$process = true;
}
if ($process == true) {
echo "Your form has been submitted successfully";
$to = "email@email.co.uk";
$subject = "PHP Form";
$message = "Yep, it seemed to work!";
$from = "email@email.co.uk";
$headers = "From: $from\r\n";
$headers .= "Reply-To: $to\r\n";
mail($to, $subject, $message, $headers);
}
} else {
?>
<form action="" method="post">
<input name="name" type="text" />
<input name="" type="submit" />
<input name="form" type="hidden" />
</form>
<?php } ?>