942,520 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1941
  • PHP RSS
Jul 9th, 2010
0

Dreamweaver PHP Contact form to email

Expand Post »
Hi, I am attempting to connect a form in Dreamweaver to an email account via a ftp webspace. I have the following generic code, (HTML form and PHP mail file) but I am not receiving emails... Would anyone have an idea of what I have done wrong and/or provide any insight to correct this problem?? Thank you in advance.

html form file
PHP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <form method="post" action="sendmail.php">
  11. Email: <input name="email" type="text" /><br />
  12. Message:<br />
  13. <textarea name="message" rows="15" cols="40">
  14. </textarea><br />
  15. <input type="submit" />
  16. </form>
  17. </body>
  18. </html>

php file to send mail
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $email = $_REQUEST['email'] ;
  3. $message = $_REQUEST['message'] ;
  4.  
  5. mail( "pro7908@setonhill.edu", "Feedback Form Results",
  6. $message, "From: $email" );
  7. header( "Location: http://www.setonhill.edul" );
  8. ?>
Similar Threads
Reputation Points: 4
Solved Threads: 0
Light Poster
cproud21 is offline Offline
42 posts
since Sep 2008
Jul 9th, 2010
0
Re: Dreamweaver PHP Contact form to email
Because you use
PHP Syntax (Toggle Plain Text)
  1. #
  2. <form method="post" action="sendmail.php">

This is the way to store the values;
$email = $_POST['email'] ;
$message = $_POST['message'] ;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Th3nutz is offline Offline
16 posts
since Mar 2010
Jul 9th, 2010
0
Re: Dreamweaver PHP Contact form to email
I tried that and Im still not getting it to work...
Reputation Points: 4
Solved Threads: 0
Light Poster
cproud21 is offline Offline
42 posts
since Sep 2008
Jul 10th, 2010
0
Re: Dreamweaver PHP Contact form to email
I don't see any ftp or dreamweaver relevant code here but i will build you a new code which works brilliantly for me.
you need to specify a content type for html coding to work.
and an id tag to retrieve the post variables

feedback form
PHP Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  4. <title>Feedback Form</title>
  5. </head>
  6. <body>
  7. <form method="post" action="sendmail.php">
  8. Email: <input id="email" name="email" type="text" /><br />
  9. Message:<br /> <textarea id="message" name="message" rows="15" cols="40"> </textarea><br /> <input type="submit" />
  10. </form></body></html>

sendmail.php
PHP Syntax (Toggle Plain Text)
  1. if (isset($_POST['email'])){
  2. /* Email Variables */
  3.  
  4. $emailSubject = 'feedback form results';
  5. $webMaster = 'pro7908@setonhill.edu';
  6.  
  7.  
  8. /* Data Variables */
  9.  
  10. $email = $_POST['email'];
  11. $message = $_POST['message'];
  12.  
  13.  
  14.  
  15. $body = <<<EOD
  16. <br><hr><br>
  17. Email: $email <br>
  18.  
  19. Message: $message<br>
  20. EOD;
  21.  
  22.  
  23. $headers = "From: $email\r\n";
  24. $headers .= "Content-type: text/html\r\n";
  25. $success = mail($webMaster, $emailSubject, $body,
  26. $headers);
  27.  
  28.  
  29. /* Results rendered as HTML */
  30.  
  31. $theResults = <<<EOD
  32. <html>
  33. <head>
  34. <title>sent message</title>
  35. <meta http-equiv="refresh" content="1;URL=http://www.setonhill.edul/">
  36. <style type="text/css">
  37. <!--
  38. body {
  39. background-color: #000;
  40. font-family: Verdana, Arial, Helvetica, sans-serif;
  41. font-size: 20px;
  42. font-style: normal;
  43. line-height: normal;
  44. font-weight: normal;
  45. color: #CCC;
  46. text-decoration: none;
  47. padding-top: 200px;
  48. margin-left: 150px;
  49. width: 800px;
  50. }
  51.  
  52. -->
  53. </style>
  54. </head>
  55. <div align="center">Your message has been received!<br />
  56. You will return to The our home page shortly</div>
  57. </div>
  58. </body>
  59. </html>
  60. EOD;
  61. echo "$theResults";
  62. }
  63. else {
  64. $theResults = <<<EOD
  65. <html>
  66. <head>
  67. <title>sent message</title>
  68. <meta http-equiv="refresh" content="1;URL=http://www.setonhill.edul/">
  69. </head>
  70.  
  71. </div>
  72. </body>
  73. </html>
  74. EOD;
  75. echo "$theResults";
  76. }
  77. ?>
Reputation Points: 13
Solved Threads: 34
Posting Whiz in Training
metalix is offline Offline
218 posts
since Mar 2010
Jul 10th, 2010
0
Re: Dreamweaver PHP Contact form to email
you should modify it to suit plus i would suggest using spry validation to check email is an email or people can get you in a lot of trouble. also it helps to prevent php injection.
to insert spry click insert ->
form ->
spry validation text field
once inserted click on the box and change properties type -> email
required and enforce pattern.
hope this helps
Reputation Points: 13
Solved Threads: 34
Posting Whiz in Training
metalix is offline Offline
218 posts
since Mar 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Nested querys not working
Next Thread in PHP Forum Timeline: doubt in mail receiving





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC