<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Toma&#039;s SEO Tips &#187; Coding</title>
	<atom:link href="http://www.optimizingtheweb.com/category/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.optimizingtheweb.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Wed, 26 May 2010 12:55:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to create a simple PHP Contact Form</title>
		<link>http://www.optimizingtheweb.com/how-to-create-a-simple-contact-form/</link>
		<comments>http://www.optimizingtheweb.com/how-to-create-a-simple-contact-form/#comments</comments>
		<pubDate>Mon, 06 Oct 2008 13:31:54 +0000</pubDate>
		<dc:creator>Toma</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://www.optimizingtheweb.com/?p=209</guid>
		<description><![CDATA[Having a contact form on your web site is very useful since the visitors can send you direct e-mails from your web sites. This contact you can place it anywhere you want : i usually have it in the contact page or guest book or request a quote page. You can also place the form [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Having a contact form on your web site is very useful since the visitors can send you direct e-mails from your web sites. This contact you can place it anywhere you want : i usually have it in the contact page or guest book or request a quote page. You can also place the form anywhere you want a feedback . The only condition is that the server you are hosting the page has to support php code.<br />
<span id="more-209"></span><br />
Here are the simple steps that need to be done :<br />
 &#8211; first we have the code to manage the information send by the form;<br />
 &#8211; then we have a java script function that checks if the fields are not empty;<br />
 &#8211; and finally the form it self.</p>
<p>Remember that the page should have a .php extension.</p>
<p>Here is the code :<br />
 This is the piece of code that is placed right at beginning of the file and that will handle the information send by the form. You notice that I have an e-mail address bellow that you can replace it with whatever address you want. Additional to the message this code will add a text to the subject : Message from website so that you know when an e-mail is sent directly from your web site.<br />
 <span style="color: #ff0000;">&lt;?php<br />
 $subject = addslashes($_REQUEST["subject"]);<br />
 $content = addslashes($_REQUEST["content"]);<br />
 $email = addslashes($_REQUEST["email"]);<br />
 $send = addslashes($_REQUEST["send"]);<br />
 $trimis = addslashes($_REQUEST["trimis"]);<br />
 $verify = addslashes($_REQUEST["verify"]);</span><br />
 <span style="color: #ff0000;"><br />
 $emailCheck = &#8220;/^[-+\\.0-9=a-z_]+@([-0-9a-z]+\\.)+([0-9a-z]){2,4}$/i&#8221;;</span><br />
 <span style="color: #ff0000;"><br />
 if($send==1 and $subject!=&#8221;" and $content!=&#8221;" and $email!=&#8221;" and $verify==&#8221;10&#8243;)<br />
 {<br />
 $subject2 = &#8220;Message from website:&#8221;.$subject;<br />
 mail(&#8220;bonciutoma@yahoo.com&#8221;, $subject2, $content, &#8220;From:&#8221;.$email);<br />
 $send = 0;<br />
 $subject = &#8220;&#8221;;<br />
 $content = &#8220;&#8221;;</span><br />
 <span style="color: #ff0000;"><br />
 $email = &#8220;&#8221;;<br />
 header(&#8220;Location: guest.php?trimis=1&#8243;);<br />
 exit;<br />
 }</span><br />
 <span style="color: #ff0000;"><br />
 ?&gt;<br />
 </span><br />
The java script function that check for the fields is this :<br />
<span style="color: #ff0000;"><br />
&lt;script type=&#8221;text/JavaScript&#8221;&gt;<br />
function VerificaForm() {<br />
var form = document.forms[0];<br />
var bRequired = true;<br />
if ((form.subject.value.length &lt; 1) || (form.email.value.length &lt; 1) || (form.content.value.length &lt; 1)  || (form.verify.value.length &lt; 1))<br />
{<br />
alert(&#8220;Completati va rog toate campurile&#8221;);<br />
bRequired = false;<br />
}</span><br />
<span style="color: #ff0000;"><br />
if (!bRequired) return false;</span><br />
<span style="color: #ff0000;"><br />
form.submit();<br />
}<br />
&lt;/script&gt;<br />
</span><br />
And finally the form that you can place it where you want on the page(don&#8217;t forget to change the page name where the form is placed in the code beloow) :<br />
<span style="color: #ff0000;"><br />
&lt;form  action=&#8221;contact.php&#8221; method=&#8221;get&#8221;  enctype=&#8221;multipart/form-data&#8221; name=&#8221;email&#8221;&gt;<br />
&lt;label&gt; &lt;span class=&#8221;textFormat&#8221;&gt;Subject&lt;/span&gt;&lt;br&gt;<br />
&lt;input name=&#8221;subject&#8221; type=&#8221;text&#8221; class=&#8221;ContactForm&#8221; id=&#8221;subject&#8221; size=&#8221;40&#8243; maxlength=&#8221;40&#8243;&gt;<br />
&lt;/label&gt;<br />
&lt;br&gt;<br />
&lt;label&gt;&lt;span class=&#8221;textFormat&#8221;&gt;Your email adress &lt;/span&gt;&lt;br&gt;<br />
&lt;input name=&#8221;email&#8221; type=&#8221;text&#8221; class=&#8221;ContactForm&#8221; id=&#8221;email&#8221; size=&#8221;40&#8243; maxlength=&#8221;40&#8243;&gt;<br />
&lt;/label&gt;<br />
&lt;br&gt;<br />
&lt;label&gt;&lt;span class=&#8221;textFormat&#8221;&gt;How much is 5+5 ?&lt;/span&gt;&lt;br&gt;<br />
&lt;input name=&#8221;verify&#8221; type=&#8221;text&#8221; class=&#8221;ContactForm&#8221; id=&#8221;email&#8221; size=&#8221;40&#8243; maxlength=&#8221;40&#8243;&gt;<br />
&lt;/label&gt;<br />
&lt;br&gt;<br />
&lt;br&gt;<br />
&lt;label&gt;&lt;span class=&#8221;textFormat&#8221;&gt;Message&lt;/span&gt;&lt;br&gt;<br />
&lt;textarea name=&#8221;content&#8221; cols=&#8221;40&#8243; rows=&#8221;15&#8243; class=&#8221;ContactForm&#8221; id=&#8221;content&#8221;&gt;&lt;/textarea&gt;<br />
&lt;/label&gt;<br />
&lt;input name=&#8221;send&#8221; type=&#8221;hidden&#8221; id=&#8221;send&#8221; value=&#8221;1&#8243;&gt;<br />
&lt;br&gt;<br />
&lt;label&gt;<br />
&lt;br /&gt;<br />
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;<br />
&lt;input name=&#8221;Update&#8221; type=&#8221;submit&#8221; class=&#8221;ContactForm&#8221; id=&#8221;Update&#8221; onClick=&#8221;VerificaForm();  return false;&#8221; value=&#8221;Send email&#8221;&gt;<br />
&lt;/label&gt;<br />
&lt;br&gt;<br />
&lt;/form&gt;<br />
</span><br />
There are also two classes that you&#8217;ll have to create in CSS if you want to format the labels and the fields : textFormat and ContactForm.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.optimizingtheweb.com/how-to-create-a-simple-contact-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
