Jump to content

contact form looks weird


cmabill

Recommended Posts

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

  1. <body>
  2. <?php
  3. $field_firstname = $_POST['firstname'];" ".$_POST['lastname'];
  4. $field_emailaddress= $_POST['emailaddress'];
  5. $field_telepohone = $_POST['telephone'];
  6. $field_country = $_POST['country'];
  7. $field_business = $_POST['business'];
  8. $field_comments = $_POST['comments'];
  9. $mail_to = 'info@ABC.com';
  10. $subject = 'Message from a site visitor '.$field_name;
  11. $body_message = 'From: '.$field_name."\n";
  12. $body_message .= 'E-mail: '.$_POST['emailaddress']."\n";
  13. $body_message .= 'Message: \n'.$_POST['emailaddress']."\n";
  14. $body_message .= $_POST['telephone']."\n";
  15. $body_message .= $_POST['country']."\n";
  16. $body_message .= $_POST['business']."\n";
  17. $body_message .= $_POST['comments'];
  18. $headers = 'From: '.$_POST['emailaddress'].'\r\n';
  19. $headers .= 'Reply-To: '.$_POST['emailaddress'].'\r\n';
  20. $mail_status = mail($mail_to, $subject, $body_message, $headers);
  21. if ($mail_status) { ?>
  22. <script language="javascript" type="text/javascript">
  23. alert('Thank you for the message. We will contact you shortly.');
  24. <!--
  25. window.location.href = "http://www.ABC.com/thankyou.html";
  26. //-->
  27. </script>
  28. <?php
  29. }
  30. else { ?>
  31. <script language="javascript" type="text/javascript">
  32. alert('Message failed. Please check the items required');
  33. <!--
  34. window.location.href = "http://www.ABC.com/contact.html";
  35. //-->
  36. </script>
  37. <?php
  38. }
  39. ?>

this is contact.html

  1. <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">
  2. <p>If you need more information about our inspection, sourcing, auditing, and verification service, <br />
  3. <br />
  4. pls contact below address or just fill in the form below, our customer service will get you back <br />
  5. <br />
  6. as soon as possible. thank you for considering ABC!</p>
  7. <p>First Name:
  8.    
  9. <label for="firstname"></label>
  10.    
  11. <input type="text" name="firstname" id="firstname" />
  12. <br />
  13. <br />
  14. Lsat Name:
  15. <label for="lastname"></label>
  16.    
  17.    
  18. <input type="text" name="lastname" id="lastname" />
  19. <br />
  20. <br />
  21. Email Address:
  22.   
  23. <label for="emailaddress"></label>
  24. <input type="text" name="emailaddress" id="emailaddress" />
  25. <br />
  26. <br />
  27. Telephone:        
  28. <label for="telephone2"></label>
  29. <input type="text" name="telephone" id="telephone" />
  30. <label for="TEL"></label>
  31. <br />
  32. <br />
  33. Country:
  34.            
  35. <label for="country"></label>
  36. <select name="country" id="country">
  37. <option>Australia</option>
  38. <option>Austria</option>
  39. <option>Belgium</option>
  40. <option>Czech Republic</option>
  41. <option>Denmark</option>
  42. <option>Finland</option>
  43. <option>France</option>
  44. <option>Germany</option>
  45. <option>Greece</option>
  46. <option>Hungary</option>
  47. <option>Italy</option>
  48. <option>Netherlands</option>
  49. <option>Norway</option>
  50. <option>Poland</option>
  51. <option>Romania</option>
  52. <option>Russia</option>
  53. <option>Spain</option>
  54. <option>Sweden</option>
  55. <option>Switzerland</option>
  56. <option>United Kingdom</option>
  57. <option>Canada</option>
  58. <option>Mexico</option>
  59. <option>United States of America</option>
  60. <option>Argentina</option>
  61. <option>Brazil</option>
  62. <option>New Zealand</option>
  63. <option>Egypt</option>
  64. <option>Iran</option>
  65. <option>Israel</option>
  66. <option>Kuwait</option>
  67. <option>Saudi Arabia</option>
  68. <option>Turkey</option>
  69. <option>Japan</option>
  70. <option>South Korea</option>
  71. <option>Vietnam</option>
  72. <option>other</option>
  73. </select>
  74. <br />
  75. <br />
  76. Business:
  77.          
  78. <label for="business"></label>
  79. <select name="business" id="business">
  80. <option>wholesale</option>
  81. <option>retail</option>
  82. <option>industrial</option>
  83. <option>services</option>
  84. <option>distributor</option>
  85. <option>manufacturer</option>
  86. <option>importer</option>
  87. <option>other</option>
  88. </select>
  89. <label for="telephone"></label>
  90. <label for="FAX"></label>
  91. <br />
  92. <br />
  93. Comments:<br />
  94. <br />
  95. <label for="comments"></label>
  96. <textarea name="comments" id="comments" cols="45" rows="5"></textarea>
  97. <br />
  98. <br />
  99.                   
  100. <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" />
  101. <br />
  102. </p>
  103. </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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.