PHP Feedback Form

Reply

Join Date: Nov 2008
Posts: 4
Reputation: pcmicro is an unknown quantity at this point 
Solved Threads: 0
pcmicro pcmicro is offline Offline
Newbie Poster

PHP Feedback Form

 
0
  #1
Dec 2nd, 2008
Good evening to all of you!

I was wondering if anyone would be willing to assist me in building an HTML feed back form powered by PHP. Quite frankly I don't care what its powered by as long as it work. Any suggestions???

Thanks for your support.

C-
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,336
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 126
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: PHP Feedback Form

 
0
  #2
Dec 2nd, 2008
I have made a standard email form and is below. The only thing you need to change is the variable $address (about line 4) to your real email address to receive website emails. Also this email form supports html formatting.
  1. <?
  2. if (isset($_POST['subject']) && $_POST['message']!=='')
  3. {
  4. $address = "your_real_email@domain.com"; //change this to the receiving address.
  5. $subject = "Website Email: ".$_POST['subject'];
  6. if ($_POST['name']!=='')
  7. {
  8. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message']."<br>
  9. <br>
  10. Yours Sincerely<br>
  11. ".$_POST['name']."</td></tr></table>";
  12. } else {
  13. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>".$_POST['message'].
  14. "</td></tr></table>";
  15. }
  16. $headers = 'MIME-Version: 1.0' . "\r\n";
  17. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  18. $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
  19.  
  20. mail($address,$subject,$body,$headers);
  21. }
  22. //below displays the form while above processes it.
  23. echo "<form method='post'>Subject: <input type=text value='' maxlength=100 name='subject' size=30><br>
  24. <textarea cols=30 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name'>
  25. <input type='submit' value='submit'></form>";
  26. ?>
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: pcmicro is an unknown quantity at this point 
Solved Threads: 0
pcmicro pcmicro is offline Offline
Newbie Poster

Re: PHP Feedback Form

 
0
  #3
Dec 7th, 2008
I have one follow-up question.
I have tinkered with this to try to add some fields and I can't seem to do it. I was wondering if you could assist me in adding some fields, in this order:
Name
Email Address
Birthday
Gender (Would it be possible to have a radio selection here?)
Finnally, I couldn't seem to edit the layout in Dreamweaver? Is there a specific way to do this? I would like to justify it and add some tables and text just to make it pretty. Thank you so much for your help!!! Take care!

Cort
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 1,336
Reputation: cwarn23 has a spectacular aura about cwarn23 has a spectacular aura about 
Solved Threads: 126
cwarn23's Avatar
cwarn23 cwarn23 is offline Offline
Nearly a Posting Virtuoso

Re: PHP Feedback Form

 
0
  #4
Dec 9th, 2008
Sorry about the late reply but this is the code that I have now made:
  1. <?
  2. if (isset($_POST['subject']) && $_POST['message']!=='')
  3. {
  4. $address = "your_real_email@domain.com"; //change this to the receiving address.
  5. $subject = "Website Email: ".$_POST['subject'];
  6. if ($_POST['name']!=='')
  7. {
  8. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
  9. .$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
  10. $_POST['gender']."<p>".$_POST['message']."<br>
  11. <br>
  12. Yours Sincerely<br>
  13. ".$_POST['name']."
  14. <p>
  15. Email: ".$_POST['email']."</td></tr></table>";
  16. } else {
  17. $body = "<table border=0 cellpadding=5 cellspacing=0 width=200><tr><td>Birthday: "
  18. .$_POST['birthday']." of ".$_POST['birthmonth']." ".$_POST['birthyear']."<br>Gender: ".
  19. $_POST['gender']."<p>".$_POST['message']."<p>Email: ".$_POST['email']."</td></tr></table>";
  20. }
  21. $headers = 'MIME-Version: 1.0' . "\r\n";
  22. $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
  23. $headers .= 'From: do_not_reply@your_website_form' . "\r\n";
  24. mail($address,$subject,$body,$headers);
  25. }
  26. //below displays the form while above processes it.
  27. echo "<form method='post'><table border=0 cellpadding=0 cellspacing=0><tr><td>Subject:</td><td align=left colspan=1><input type=text value='' maxlength=100 name='subject' size=35></td></tr><tr><td>Email:</td><td align=left colspan=1><input type=text value='' name='email' size=35></td></tr><tr><td>Birthday:</td><td colspan=1 rowspan=2><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><select name='birthday' size=1>
  28. <option value='1'>1</option>
  29. <option value='2'>2</option>
  30. <option value='3'>3</option>
  31. <option value='4'>4</option>
  32. <option value='5'>5</option>
  33. <option value='6'>6</option>
  34. <option value='7'>7</option>
  35. <option value='8'>8</option>
  36. <option value='9'>9</option>
  37. <option value='10'>10</option>
  38. <option value='11'>11</option>
  39. <option value='12'>12</option>
  40. <option value='13'>13</option>
  41. <option value='14'>14</option>
  42. <option value='15'>15</option>
  43. <option value='16'>16</option>
  44. <option value='17'>17</option>
  45. <option value='18'>18</option>
  46. <option value='19'>19</option>
  47. <option value='20'>20</option>
  48. <option value='21'>21</option>
  49. <option value='22'>22</option>
  50. <option value='23'>23</option>
  51. <option value='24'>24</option>
  52. <option value='25'>25</option>
  53. <option value='26'>26</option>
  54. <option value='27'>27</option>
  55. <option value='28'>28</option>
  56. <option value='29'>29</option>
  57. <option value='30'>30</option>
  58. <option value='31'>31</option>
  59. </select><select name='birthmonth' size=1>
  60. <option value='January'>Jan</option>
  61. <option value='February'>Feb</option>
  62. <option value='March'>Mar</option>
  63. <option value='April'>Apr</option>
  64. <option value='May'>May</option>
  65. <option value='June'>Jun</option>
  66. <option value='July'>Jul</option>
  67. <option value='August'>Aug</option>
  68. <option value='September'>Sep</option>
  69. <option value='October'>Oct</option>
  70. <option value='November'>Nov</option>
  71. <option value='December'>Dec</option>
  72. </select><input size=7 maxlength=4 name='birthyear'></td></tr><tr><td>   Male:<input type='radio' name='gender' value='Male'></td><td align='right'>Female:<input type='radio' name='gender' value='Female'></td></tr></table></td></tr><tr><td>Gender:</td></tr><tr><td colspan=3><textarea cols=35 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name' size=28><input type='submit' value='submit'></td></tr></table></form>";
  73. ?>
Above is the form with the extra fields added. Also, as for your question about dreamweaver, perhaps dreamweaver is not php echo friendly. So place the below code into dreamweaver and after using dreamweaver, place dreamweavers contact form code within the last echo function of the code above. Also make sure the double quotation (") is not used within the dreamweaver code otherwise it will cause a php error. Instead use the single quotation (').
  1. <form method='post'><table border=0 cellpadding=0 cellspacing=0><tr><td>Subject:</td><td align=left colspan=1><input type=text value='' maxlength=100 name='subject' size=35></td></tr><tr><td>Email:</td><td align=left colspan=1><input type=text value='' name='email' size=35></td></tr><tr><td>Birthday:</td><td colspan=1 rowspan=2><table border=0 cellpadding=0 cellspacing=0><tr><td colspan=2><select name='birthday' size=1>
  2. <option value='1'>1</option>
  3. <option value='2'>2</option>
  4. <option value='3'>3</option>
  5. <option value='4'>4</option>
  6. <option value='5'>5</option>
  7. <option value='6'>6</option>
  8. <option value='7'>7</option>
  9. <option value='8'>8</option>
  10. <option value='9'>9</option>
  11. <option value='10'>10</option>
  12. <option value='11'>11</option>
  13. <option value='12'>12</option>
  14. <option value='13'>13</option>
  15. <option value='14'>14</option>
  16. <option value='15'>15</option>
  17. <option value='16'>16</option>
  18. <option value='17'>17</option>
  19. <option value='18'>18</option>
  20. <option value='19'>19</option>
  21. <option value='20'>20</option>
  22. <option value='21'>21</option>
  23. <option value='22'>22</option>
  24. <option value='23'>23</option>
  25. <option value='24'>24</option>
  26. <option value='25'>25</option>
  27. <option value='26'>26</option>
  28. <option value='27'>27</option>
  29. <option value='28'>28</option>
  30. <option value='29'>29</option>
  31. <option value='30'>30</option>
  32. <option value='31'>31</option>
  33. </select><select name='birthmonth' size=1>
  34. <option value='January'>Jan</option>
  35. <option value='February'>Feb</option>
  36. <option value='March'>Mar</option>
  37. <option value='April'>Apr</option>
  38. <option value='May'>May</option>
  39. <option value='June'>Jun</option>
  40. <option value='July'>Jul</option>
  41. <option value='August'>Aug</option>
  42. <option value='September'>Sep</option>
  43. <option value='October'>Oct</option>
  44. <option value='November'>Nov</option>
  45. <option value='December'>Dec</option>
  46. </select><input size=7 maxlength=4 name='birthyear'></td></tr><tr><td>   Male:<input type='radio' name='gender' value='Male'></td><td align='right'>Female:<input type='radio' name='gender' value='Female'></td></tr></table></td></tr><tr><td>Gender:</td></tr><tr><td colspan=3><textarea cols=35 rows=20 name='message'></textarea><br>Name: <input type='text' value='' name='name' size=28><input type='submit' value='submit'></td></tr></table></form>
Hope that helps
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 132
Reputation: rajeesh_rsn is an unknown quantity at this point 
Solved Threads: 0
rajeesh_rsn rajeesh_rsn is offline Offline
Junior Poster

Re: PHP Feedback Form

 
0
  #5
Dec 13th, 2008
Why dont you try it with a simple txt file. When user submit data then it will store in a txt file which keep in our server ..... safe and secure .....<EMAIL SNIPPED> for more details and code ....
Last edited by peter_budo; Dec 13th, 2008 at 4:54 pm. Reason: Keep it On The Site - Do not post asking for an answer to be sent to you via email or PM.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: pcmicro is an unknown quantity at this point 
Solved Threads: 0
pcmicro pcmicro is offline Offline
Newbie Poster

Re: PHP Feedback Form

 
0
  #6
Jan 10th, 2009
Rajeesh,
Can you shed some light on your recommendation, I would like to learn more! Also what do you think of building a java script web form, these also seem fairly straight forward. Any ideas?
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 1,267
Reputation: almostbob has a spectacular aura about almostbob has a spectacular aura about 
Solved Threads: 159
almostbob's Avatar
almostbob almostbob is offline Offline
Nearly a Posting Virtuoso

Re: PHP Feedback Form

 
0
  #7
Jan 11th, 2009
  1. //write text.php
  2. // Get the user details.
  3. $getdate = date( 'd-m-Y, H:i:s' );// Get the date.
  4. $user_ip = $_SERVER['REMOTE_ADDR'];// Get the users IP.just in case
  5. $referer = getenv("HTTP_REFERER");// Get the refering page. just in case
  6. // Look for the text file and open it for writting.
  7. $file = "./logfiles/logfile.csv";// define the text file. Note I am using a .csv file, it is still text but opens in excell for manipulation when I remember to check it
  8. $fp = fopen($file, "a+");//open the text file for writing.
  9. // Write into the text file.
  10. fputs ($fp, "$user_ip,$getdate, $referer, $data1, \n"); //$data1 can be any number of data fields required to match the form,
  11. fclose($fp);// Close the text file.
The scrap above can be appended to any php form and write to the texfile as part of the php form processing, checking IP and referrer helps reduce obvious dodgy entries.
Javasript on the user side, and php at the server, is pretty much AJAX, and can do really impressive things, the form handlers you look for may be for download at hotscripts, sourceforge, javascript.net or one of the other script repositories
If(!$referer==$_SERVER['php_self']) die('data must submitted from the online form'); just crossed my mind assuming this is a self processed form (action='<?php echo $_SERVER['PHP_SELF']; ?>')
Last edited by almostbob; Jan 11th, 2009 at 1:09 am.
Failure is not an option It's included free
If at first you dont succeed, join the club
Please mark solved problems, solved
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC