944,117 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4293
  • PHP RSS
Jan 5th, 2005
0

Need Web Based Contact Us Form

Expand Post »
Hey all,

I figured for my new website that it is easier to have a contact us form, instead of just having my e-mail address. I have searched Google and Hotscripts (http://hotscripts.com) and I have not found anything that is free and easy. I am looking for a first name field, e-mail address, subject (drop down menu) and message. I want all that information sent to me from the form. My server supports PHP, and most other file types. Does anyone know where to find this information? (I would prefer if it was already built, instead of a tutorial.)

Thanks,

Internet_Sense


Internet Sense

Internet News, Articles, and More!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Internet_Sense is offline Offline
10 posts
since Jan 2005
Jan 5th, 2005
0

Re: Need Web Based Contact Us Form

how much php do you know? you could make a simple form that you "post", once it is posted just use the php mail function. If your not sure exactly what I mean then reply to this message and i could do a very simple example
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Jan 5th, 2005
0

Re: Need Web Based Contact Us Form

ok ok, so i got bored and decided to quickly write the code you needed, but make sure to place your email address inside of the quotes on line 2!! or this will all be for not!

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $to = "PUT__YOUR__EMAIL__ADDRESS__HERE!!!";
  3. ?>
  4. <html>
  5. <head>
  6. <title>Contact Us</title>
  7. </head>
  8. <body>
  9.  
  10. <?
  11. if (isset($_POST['submit']))
  12. {
  13.  
  14. $headers = "MIME-Version: 1.0\r\n";
  15. $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  16. $headers .= "From: ".$_POST['name']." <".$_POST['email'].">\r\n";
  17. $headers .= "Reply-To: <".$_POST['email'].">\r\n";
  18. $headers .= "X-Sender: <".$_POST['email'].">\r\n";
  19. $headers .= "X-Priority: 3\r\n"; //1 UrgentMessage, 3 Normal
  20. $headers .= "Return-Path: <webmaster@domain.com>\r\n";
  21.  
  22. if (@mail($to,$_POST['subject'],$_POST['message'],$headers))
  23. {
  24. echo "<h2>Your message was submitted</h2>";
  25. }
  26. else
  27. {
  28. echo "<h2><b>Whoops we seemed to have encountered an error submitting your message!</b></h2>";
  29. }
  30. }
  31. else
  32. {
  33. echo printForm();
  34. }
  35.  
  36. echo "\n</body>\n</html>";
  37. exit();
  38.  
  39.  
  40. function printForm()
  41. {
  42.  
  43. $html = "\n\t<form method=\"post\">";
  44. $html .= "\n\t<table width=\"550\" border=\"0\">";
  45.  
  46. $html .= "\n\t\t<tr>";
  47. $html .= "\n\t\t\t<td align=\"right\">Your Name:</td>";
  48. $html .= "\n\t\t\t<td><input type=\"text\" name=\"name\" size=\"35\" maxlength=\"255\" value=\"\"></td>";
  49. $html .= "\n\t\t</tr>";
  50.  
  51. $html .= "\n\t\t<tr>";
  52. $html .= "\n\t\t\t<td nowrap align=\"right\">Your Email Address:</td>";
  53. $html .= "\n\t\t\t<td><input type=\"text\" name=\"email\" size=\"35\" maxlength=\"75\" value=\"\"></td>";
  54. $html .= "\n\t\t</tr>";
  55.  
  56. $html .= "\n\t\t<tr>";
  57. $html .= "\n\t\t\t<td align=\"right\">Subject:</td>";
  58. $html .= "\n\t\t\t<td><input type=\"text\" name=\"subject\" size=\"35\" maxlength=\"255\" value=\"\"></td>";
  59. $html .= "\n\t\t</tr>";
  60.  
  61. $html .= "\n\t\t<tr>";
  62. $html .= "\n\t\t\t<td align=\"right\">Message:</td>";
  63. $html .= "\n\t\t\t<td><textarea name=\"message\" rows=\"15\" cols=\"55\"></textarea></td>";
  64. $html .= "\n\t\t</tr>";
  65.  
  66. $html .= "\n\t\t<tr>";
  67. $html .= "\n\t\t\t<td align=\"right\">&nbsp; </td>";
  68. $html .= "\n\t\t\t<td align=\"center\"><input name=\"submit\" type=\"submit\" value=\"Submit\"></td>";
  69. $html .= "\n\t\t</tr>";
  70.  
  71. $html .= "\n\t</table>";
  72. $html .= "\n\t</form>";
  73.  
  74. return $html;
  75. }
  76. ?>


some other things you could do to improve the quality of this is validing the users email address or even appending there IP address, perhaps adding this to the users text:

$_SERVER["HTTP_USER_AGENT"]
which in my case would be:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0

that would show the users OS and browser type this would be particulary useful if they had a problem accessing your homepage ... aka there using firefox and you've designed your webpage for IE with CSS (since Microsoft has there own css standards) etc... etc...
Reputation Points: 13
Solved Threads: 4
Posting Whiz
paradox814 is offline Offline
351 posts
since Oct 2004
Jan 6th, 2005
0

Re: Need Web Based Contact Us Form

Thank you for your help.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Internet_Sense is offline Offline
10 posts
since Jan 2005
Nov 27th, 2009
0

A PHP Contact Form For Your Web Site

Hi,
You can get the exact form that you are looking for at [SNIP], no tutorials, no headache, just upload your form page to your web site.

Genesisgrace


Hey all,

I figured for my new website that it is easier to have a contact us form, instead of just having my e-mail address. I have searched Google and Hotscripts (http://hotscripts.com) and I have not found anything that is free and easy. I am looking for a first name field, e-mail address, subject (drop down menu) and message. I want all that information sent to me from the form. My server supports PHP, and most other file types. Does anyone know where to find this information? (I would prefer if it was already built, instead of a tutorial.)

Thanks,

Internet_Sense


Internet Sense

Internet News, Articles, and More!
Last edited by Ezzaral; Nov 29th, 2009 at 2:13 pm. Reason: Removed solicitation.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
genesisgrace is offline Offline
6 posts
since Nov 2009
Nov 27th, 2009
-1
Re: Need Web Based Contact Us Form
Seeing as you're a newbie, I won't downvote you, but get a grip. This thread is over 4 years old. If you want to contribute, pick a current-ish thread or start your own.
Sponsor
Featured Poster
Reputation Points: 1067
Solved Threads: 955
Disgraced Poster
ardav is offline Offline
6,728 posts
since Oct 2006
Nov 27th, 2009
0
Re: Need Web Based Contact Us Form
If this thread were over, how comes you are reading it?! There is always something to learn from the new and the old. This thread is still up for a reason.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
genesisgrace is offline Offline
6 posts
since Nov 2009
May 12th, 2010
0
Re: Need Web Based Contact Us Form
If you don't want to build anything and simply want to copy a code and paste your web page to capture information, try http://www.quickwebform.com. It's free.
Last edited by naping; May 12th, 2010 at 1:11 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
naping is offline Offline
3 posts
since May 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: docx/doc online viewer
Next Thread in PHP Forum Timeline: I want to publish a site





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


Follow us on Twitter


© 2011 DaniWeb® LLC