•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 423,523 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,357 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 3026 | Replies: 3
![]() |
•
•
Join Date: Jan 2005
Posts: 9
Reputation:
Rep Power: 0
Solved Threads: 0
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!
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!
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 2
•
•
Join Date: Oct 2004
Location: San Francisco, CA
Posts: 338
Reputation:
Rep Power: 4
Solved Threads: 2
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!
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...
<?php
$to = "PUT__YOUR__EMAIL__ADDRESS__HERE!!!";
?>
<html>
<head>
<title>Contact Us</title>
</head>
<body>
<?
if (isset($_POST['submit']))
{
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: ".$_POST['name']." <".$_POST['email'].">\r\n";
$headers .= "Reply-To: <".$_POST['email'].">\r\n";
$headers .= "X-Sender: <".$_POST['email'].">\r\n";
$headers .= "X-Priority: 3\r\n"; //1 UrgentMessage, 3 Normal
$headers .= "Return-Path: <webmaster@domain.com>\r\n";
if (@mail($to,$_POST['subject'],$_POST['message'],$headers))
{
echo "<h2>Your message was submitted</h2>";
}
else
{
echo "<h2><b>Whoops we seemed to have encountered an error submitting your message!</b></h2>";
}
}
else
{
echo printForm();
}
echo "\n</body>\n</html>";
exit();
function printForm()
{
$html = "\n\t<form method=\"post\">";
$html .= "\n\t<table width=\"550\" border=\"0\">";
$html .= "\n\t\t<tr>";
$html .= "\n\t\t\t<td align=\"right\">Your Name:</td>";
$html .= "\n\t\t\t<td><input type=\"text\" name=\"name\" size=\"35\" maxlength=\"255\" value=\"\"></td>";
$html .= "\n\t\t</tr>";
$html .= "\n\t\t<tr>";
$html .= "\n\t\t\t<td nowrap align=\"right\">Your Email Address:</td>";
$html .= "\n\t\t\t<td><input type=\"text\" name=\"email\" size=\"35\" maxlength=\"75\" value=\"\"></td>";
$html .= "\n\t\t</tr>";
$html .= "\n\t\t<tr>";
$html .= "\n\t\t\t<td align=\"right\">Subject:</td>";
$html .= "\n\t\t\t<td><input type=\"text\" name=\"subject\" size=\"35\" maxlength=\"255\" value=\"\"></td>";
$html .= "\n\t\t</tr>";
$html .= "\n\t\t<tr>";
$html .= "\n\t\t\t<td align=\"right\">Message:</td>";
$html .= "\n\t\t\t<td><textarea name=\"message\" rows=\"15\" cols=\"55\"></textarea></td>";
$html .= "\n\t\t</tr>";
$html .= "\n\t\t<tr>";
$html .= "\n\t\t\t<td align=\"right\"> </td>";
$html .= "\n\t\t\t<td align=\"center\"><input name=\"submit\" type=\"submit\" value=\"Submit\"></td>";
$html .= "\n\t\t</tr>";
$html .= "\n\t</table>";
$html .= "\n\t</form>";
return $html;
}
?>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...
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
adult advertising blog browser browsing community company competition data design development domains firefox google html india intel internet legal linux marketing math microsoft mobile applications monetization mozilla msn multimedia news php privacy report research revenue rss search security sex software standards sun technology video w3c web web development webmaster wiki xml yahoo
- Need a contact form for my web site (Site Layout and Usability)
- Cannot Connect to, Linksys' Web Based Utility, I need help (Networking Hardware Configuration)
- Form isn't working. (HTML and CSS)
- social web-based applications ???, pls help (Web Developers' Lounge)
- Removing pictures from Outlook 2003 Contact form (Windows Software)
- Advice required to start WEB based application development (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: limit the number of downloads
- Next Thread: parsing csv file


Linear Mode