PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I've been trying to work this out for a while now but can't find any similar scenario. I taught myself PHP to build a specific website. Here is the page in question:
My problem is that I can only get it to work if both <form> elements are present in the code below - if I remove the first form element it seems to post to itself or something, refreshing the page; removing the values from the form and putting the values from the form into the address bar.
Having two form elements is only a problem for IE too - seems to try and render another big section (i hate IE!)
Sorry if this has been covered or its an obvious problem - I can't get my head round it!!
action="Thanks" is definitely wrong. This should either point to a URL or be left blank. The first form and the link under it don't serve any purpose. Remove them.
Unfortunately that hasn't worked - its still just refreshing the page and posting the values to the URL instead... I've uploaded it to the site so you can try if that helps.
<?php $name = $_POST['name'];
$email = $_POST['email'];
if ($email == "") $email = "form@crabtree-confectionery.co.uk";
$message = $_POST['message'];
$phone = $_POST['phone'];
$QueryType = $_POST['QueryType'];
$mailheader = "MIME-Version: 1.0\n";
$mailheader .= "Content-type: text/plain; charset=iso-8859-1\n";
$formcontent="From: $name \n Phone: $phone \n Query Type: $QueryType \n Message: \n $message";
$recipient = "crabtree.confectionery@gmail.com";
$subject = "Crabtree Confectionery Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error! Please go back and try again. If this continues please use the email address and let us know there was a problem.");
?>
<?php include 'Includes/head.php';?>
<?php include 'Includes/header.php';?>
<h2>
Thanks
</h2>
<p>
</p>
<div id="container">
<div class="leftContentLarge">
<div class="titleContent">
</div>
<table class="tables" style="border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px;
border: 1px solid #000; padding: 10px; -webkit-box-shadow: 5px 5px 10px #000">
<tr>
<td>
<b>Thanks for contacting us</b>
<br><br>
We will be in contact soon.
<br><br>
If you are making a booking, we will contact you to confirm and arrange payment.
<br><br>
</td>
</tr>
</table>
</div>
<?php include 'Includes/footer.php';?>
Run your page through the W3C Markup Validation Service. There are some problems with the HTML that the service will identify for you. The first thing to fix is the conflicting doctypes, which you will see if you view the HTML source of the Contact page. Also, there are nested forms.