I have a quick question that has been bugging me all day. I am creating a website with a php form in it. If it is completed you are allowed to see the pdf download link. If you don’t fill out all the fields it shows the “There is a missing field on the form. Please make sure that you have entered the correct details in the boxes provided!” like requested. If you do fill it out correctly it does not show “Thank you! Click here to view this product’s online PDF catalog!” as requested.
This is the form online to see for yourself: http://precisionmotionproducts.com/Catalog_SD.php
The code is as follows. PHP is in the same document as the html .
<?php if($_POST['submit']) { if(empty($_POST['name']) || empty($_POST['company']) || empty($_POST['telephone']) || empty($_POST['email'])) { $error = true; } else { $to = "[email protected]"; $name = trim($_POST['name']); $company = trim($_POST['company']); $telephone = trim($_POST['telephone']); $email = trim($_POST['email']); $subject = "Contact Form"; $messages = "Name: $name \r\n Company: $company \r\n Telephone: $telephone \r\n Email: $email \r\n Screw/Trap Drive and Components"; $headers= "From:" . $none; $mailsent = mail($to, $subject, $messages, $headers); if($mailsent) { $sent = true; } } } ?> ICB-USAICB-Greenline Catalog Form
<?php if($error == true) { ?>There is a missing field on the form. Please make sure that you have entered the correct details in the boxes provided!
<?php } if($sent == true) { ?>Thank you! Click here to view this product's online PDF catalog!
<?php } ?><div id="contactform">
<form name="contact" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label for="name">Name:</label>
<input type="text" name="name" />
<label for="company">Company:</label>
<input type="company" name="company" />
<label for="telephone">Telephone:</label>
<input type="telephone" name="telephone" />
<label for="email">E-mail:</label>
<input type="email" name="email" />
<input type="submit" name="submit" class="submit" value="Get Catalog" />
</form>
<div style="clear:both;"></div>
<div class="call1">
<img src="tpic/phone_nb_2.png" width="115" height="86" alt="phoneimg" />
</div>
<div class="call2">
<font color="#FFFFFF">704-333-3377</font>
</div>
<div class="fax1">
<img src="tpic/fax_nb_2.png" width="115" height="86" alt="faximg" /></div>
<div class="fax2">
<font color="#FFFFFF">704-334-6146</font>
</div>
<div class="email1">
<a href="contactform.php"><img src="tpic/email_nb_2.png" width="115" height="86" alt="emailimg" /></a></div>
<div class="email2">
<font color=#FFFFFF>[email protected]</font>
</div>
</div>
Precision in Motion
Please tell me what I did wrong, as it worked when I was previewing the site. Thanks for your time in advance.