cmabill Posted January 11, 2013 Share Posted January 11, 2013 contact form weird I could receive the email but my php has some problem which makes the receving email looks strange, and can't use reply function on outlook. anyone could help me improve it. thank you. this contact.php <body> <?php $field_firstname = $_POST['firstname'];" ".$_POST['lastname']; $field_emailaddress= $_POST['emailaddress']; $field_telepohone = $_POST['telephone']; $field_country = $_POST['country']; $field_business = $_POST['business']; $field_comments = $_POST['comments']; $mail_to = 'info@ABC.com'; $subject = 'Message from a site visitor '.$field_name; $body_message = 'From: '.$field_name."\n"; $body_message .= 'E-mail: '.$_POST['emailaddress']."\n"; $body_message .= 'Message: \n'.$_POST['emailaddress']."\n"; $body_message .= $_POST['telephone']."\n"; $body_message .= $_POST['country']."\n"; $body_message .= $_POST['business']."\n"; $body_message .= $_POST['comments']; $headers = 'From: '.$_POST['emailaddress'].'\r\n'; $headers .= 'Reply-To: '.$_POST['emailaddress'].'\r\n'; $mail_status = mail($mail_to, $subject, $body_message, $headers); if ($mail_status) { ?> <script language="javascript" type="text/javascript"> alert('Thank you for the message. We will contact you shortly.'); <!-- window.location.href = "http://www.ABC.com/thankyou.html"; //--> </script> <?php } else { ?> <script language="javascript" type="text/javascript"> alert('Message failed. Please check the items required'); <!-- window.location.href = "http://www.ABC.com/contact.html"; //--> </script> <?php } ?> this is contact.html <form action="contact.php" method="post" name="form1" target="_blank" class="email" id="form1" onsubmit="MM_validateForm('firstname','','R','lastname','','R','emailaddress','','NisEmail','comments','','R');return document.MM_returnValue"> <p>If you need more information about our inspection, sourcing, auditing, and verification service, <br /> <br /> pls contact below address or just fill in the form below, our customer service will get you back <br /> <br /> as soon as possible. thank you for considering ABC!</p> <p>First Name: <label for="firstname"></label> <input type="text" name="firstname" id="firstname" /> <br /> <br /> Lsat Name: <label for="lastname"></label> <input type="text" name="lastname" id="lastname" /> <br /> <br /> Email Address: <label for="emailaddress"></label> <input type="text" name="emailaddress" id="emailaddress" /> <br /> <br /> Telephone: <label for="telephone2"></label> <input type="text" name="telephone" id="telephone" /> <label for="TEL"></label> <br /> <br /> Country: <label for="country"></label> <select name="country" id="country"> <option>Australia</option> <option>Austria</option> <option>Belgium</option> <option>Czech Republic</option> <option>Denmark</option> <option>Finland</option> <option>France</option> <option>Germany</option> <option>Greece</option> <option>Hungary</option> <option>Italy</option> <option>Netherlands</option> <option>Norway</option> <option>Poland</option> <option>Romania</option> <option>Russia</option> <option>Spain</option> <option>Sweden</option> <option>Switzerland</option> <option>United Kingdom</option> <option>Canada</option> <option>Mexico</option> <option>United States of America</option> <option>Argentina</option> <option>Brazil</option> <option>New Zealand</option> <option>Egypt</option> <option>Iran</option> <option>Israel</option> <option>Kuwait</option> <option>Saudi Arabia</option> <option>Turkey</option> <option>Japan</option> <option>South Korea</option> <option>Vietnam</option> <option>other</option> </select> <br /> <br /> Business: <label for="business"></label> <select name="business" id="business"> <option>wholesale</option> <option>retail</option> <option>industrial</option> <option>services</option> <option>distributor</option> <option>manufacturer</option> <option>importer</option> <option>other</option> </select> <label for="telephone"></label> <label for="FAX"></label> <br /> <br /> Comments:<br /> <br /> <label for="comments"></label> <textarea name="comments" id="comments" cols="45" rows="5"></textarea> <br /> <br /> <input name="submit" type="submit" id="submit" onclick="MM_validateForm('firstname','','R','lastname','','R','emailaddress','','RisEmail','telephone','','NisNum','comments','','R');return document.MM_returnValue" value="Submit" /> <br /> </p> </form> another problem is that the verification function doesn't work, people could send me blank email, but when I try myself, it works. thank you for you help. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 11, 2013 Share Posted January 11, 2013 Please use the [code][/code] tags around your code, as it helps make both your post and your code a lot easier to read, and don't manually enumerate the lines. Also, "looks weird" doesn't tell us anything. You need to accurately describe what you're seeing, and what you expected to see. Preferably with images, highlighting the differences. What you really should do, is to stop using DreamWeaver to generate your code, learn the languages properly, and take control. DreamWeaver code is a perfect example of how not to do things. Reason you're getting blank mails is that there is no (server-side) validation in that form, and it's completely devoid of any security. There are lots and lots of resources here on how to create a secure contact form, including ready-made solutions which you can just drop in. Either way, you need to read more up on input validation and general security. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.