<?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>Dev Tips &#124; Become a Better Developer, One Tip at a Time. &#187; Server Side</title>
	<atom:link href="http://dev-tips.com/category/server-side/feed" rel="self" type="application/rss+xml" />
	<link>http://dev-tips.com</link>
	<description>Become a Better Developer, One Tip at a Time.</description>
	<lastBuildDate>Sun, 07 Mar 2010 02:19:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Creating Unique Styles for WordPress Pages</title>
		<link>http://dev-tips.com/featured/creating-unique-styles-for-wordpress-pages</link>
		<comments>http://dev-tips.com/featured/creating-unique-styles-for-wordpress-pages#comments</comments>
		<pubDate>Sun, 07 Mar 2010 02:07:23 +0000</pubDate>
		<dc:creator>Nick Plekhanov</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=893</guid>
		<description><![CDATA[In WordPress 2.8, there is one small but very useful feature, both for WP web developers, and for bloggers. This is an opportunity to change the appearance of any individual page or group of pages without the need to write either the functions/conditions on php or install plugins. All you need to do is simply [...]]]></description>
			<content:encoded><![CDATA[<p>In WordPress 2.8, there is one small but very useful feature, both for WP web developers, and for bloggers. This is an opportunity to change the appearance of any individual page or group of pages without the need to write either the functions/conditions on php or install plugins. All you need to do is simply add your desired style to your css file.</p>
<p><span id="more-893"></span></p>
<h2>How does it work? </h2>
<p>In WordPress 2.8 has been added to the function <code>body_class()</code>. It works like so</p>
<pre class="brush: php">
&lt;body &lt;?php body_class(); ?&gt;&gt;
</pre>
<p> So, we just need to apply such function to the body.</p>
<p>If your theme is adapted for WordPress 2.8, this feature is probably already present in the code. In case you can’t find that function, it's enough to search for
<pre class="brush: html">&lt;body&gt;</pre>
<p> tag in <code>header.php</code> file of your theme and replace it with </p>
<pre class="brush: php">
&lt;body &lt;?php body_class(); ?&gt;&gt;
</pre>
<h2>Usage</h2>
<p>What do we get from using this function? It’s very simply; we get a &lt;body&rt; tag with additional classes, such as:<br />
&lt;body class="home blog"&rt;<br />
or<br />
&lt;body class=" single postid-1001 parent-page-id-0 page-template-default"&rt;</p>
<p>What does this give us? Let’s look at some examples.</p>
<p>Adding to your website’s css file:</p>
<pre class="brush: css">
.postid-3 #respond{

display: none; 

}
</pre>
<p>Will kill comments form from post with id=3, just leaving comments.</p>
<hr />
<pre class="brush: css">
.home{

background: #f00;

}
</pre>
<p>Only make the background of the home page in red.</p>
<hr />
<pre class="brush: css">
.page h2{

font-size: 30px;

}
</pre>
<p>Increases the size of the header only on the pages (not blog entries) of the site.</p>
<p>Anyway, these are just simple examples. Using this feature you can make almost any changes in the CSS file for a single page or page group.</p>
<h2>Documentation</h2>
<p>Below you can see a full list of body classes that can be used for custom styling (just apply desired styles to them). That long list lets us know that style can be applied to almost any page, even to the third page of a search results, even to the tag, even to the author.</p>
<ul>
<li>rtl </li>
<li>home </li>
<li>blog </li>
<li>archive </li>
<li>date </li>
<li>search </li>
<li>paged </li>
<li>attachment </li>
<li>error404 </li>
<li>single postid-(id)</li>
<li>attachmentid-(id) </li>
<li>attachment-(mime-type) </li>
<li>author </li>
<li>author-(name) </li>
<li>category </li>
<li>category-(name) </li>
<li>tag </li>
<li>tag-(name) </li>
<li>page</li>
<li>page-parent </li>
<li>page-child parent-pageid-(id) </li>
<li>page-template page-template-(template file name) </li>
<li>search-results </li>
<li>search-no-results</li>
<li>logged-in </li>
<li>paged-(page number) </li>
<li>single-paged-(page number) </li>
<li>page-paged-(page number) </li>
<li>category-paged-(page number) </li>
<li>tag-paged-(page number) </li>
<li>date-paged-(page number) </li>
<li>author-paged-(page number) </li>
<li>search-paged-(page number)</li>
</ul>
<p>For WordPress huge fans and those who wants more, there is an opportunity to add their custom classes to body_class via a standard WordPress way:</p>
<pre class="brush: php">
&lt;?php
add_filter(&#039;body_class&#039;,&#039;my_body_classes&#039;);
function my_body_classes($classes, $class) {
	// add &#039;my-class&#039; to the $classes array
	$classes[] = &#039;my-class&#039;;
	// return the $classes array
	return $classes;
}
?&gt;
</pre>
<p>There is no official documentation for body_class() at the moment, but as usually happens in WordPress, the function is made very simply and wisely. So, it is not difficult to understand it. A little more details can be found in the body_class() function’s code.</p>
<p>Thank you and good luck! <img src='http://dev-tips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/creating-unique-styles-for-wordpress-pages/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP For Absolute Beginners Reviewed + Giveaway!</title>
		<link>http://dev-tips.com/featured/php-for-absolute-beginners-reviewed-giveaway</link>
		<comments>http://dev-tips.com/featured/php-for-absolute-beginners-reviewed-giveaway#comments</comments>
		<pubDate>Tue, 08 Dec 2009 09:34:39 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[Book Review]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=682</guid>
		<description><![CDATA[Recently, fellow web developer and friend, Jason Lengstorf wrote and published (by Apress Publishing) PHP for Absolute Beginners. Jason was kind enough to send me a copy for my own reading and enjoyment. Now that I've finished, I'll be quickly reviewing the book and then giving away a free copy to one of our readers, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, fellow web developer and friend, <a href='http://ennuidesign.com/' title='Ennui Design'>Jason Lengstorf</a> wrote and published (by Apress Publishing) <a href="http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738">PHP for Absolute Beginners.</a><img src="http://www.assoc-amazon.com/e/ir?t=devtips-20&#038;l=as2&#038;o=1&#038;a=1430224738" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p>
<p> Jason was kind enough to send me a copy for my own reading and enjoyment. Now that I've finished, I'll be quickly reviewing the book and then giving away a free copy to one of our readers, courtesy of Jason Lengstorf and Apress Publishing! Read on to find out more about the book and how to win the giveaway!
</p>
<p><span id="more-682"></span></p>
<div><a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738' title='PHP For Absolute Beginners Review and Giveaway'><img alt="" src="http://dev-tips.com/post_img/php_absolute_review_image.png" title="PHP For Absolute Beginners Review and Giveaway!" class="aligncenter" width="370" height="457" /></a></div>
<p><a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738'>You can grab the book on Amazon</a> right now as an early Christmas or Holiday gift to yourself, and start learning php today!</p>
<h2>Overall Thoughts</h2>
<p>The book was awesome, seriously, it was awesome. I say this as someone who has already had a lot of experience working with php, in fact, I make most of my living writing PHP code.</p>
<p>Don't believe me eh? It's so good, I gave it one thumb up! <strong>It would have gotten two</strong>, but I needed one hand to hold it:</p>
<div><div id="attachment_696" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738"><img src="http://dev-tips.com/wp-content/uploads/2009/12/Photo-47-300x225.png" alt="Drew Approves of This Book" title="PHP For Absolute Beginners Book" width="300" height="225" class="size-medium wp-image-696" /></a><p class="wp-caption-text">Drew Approves of This Book</p></div></div>
<h2>Target Audience</h2>
<p>Mostly beginners, but can be used as a great refresher or reference book for intermediate to advanced users.</p>
<p><strong>Do not let the title fool you, this book is no small book!</strong> <em><a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738'>PHP For Absolute Beginners</a></em> is quite a chunky book, filled with useful information and sample tutorials. Towards the last half of the book, you are walked step by step through building a nice web application.</p>
<p>If you're looking to get started with php, hands down this is the book you want to pick up first. It is not too overwhelming while at the same time stays extremely informative and in depth.</p>
<h2>Topics I Found Useful</h2>
<p>While there are a ton of valuable resources and topics in the book, a few of them stuck out to me as great references and guides:</p>
<ul>
<li>MySQLi Refresher and References</li>
<li>PDO (PHP Data Objects) and DB Abstraction is taught step by step and encouraged.</li>
<li>PHP security and best practices are dealt with immediately.</li>
<li>Great XML and RSS Feed section.</li>
</ul>
<h2>Want a Free Copy?</h2>
<p>We're giving away a copy of <em><a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738'>PHP For Absolute Beginners</a></em> absolutely free! Read the details below to find out how to win!</p>
<ul>
<li>Make a quick tweet about this giveaway/review on Twitter, please include the hashtag <code>#DevTipsGiveaway</code> in your tweet. Here is a short URL to the post you can use - <code>http://bit.ly/6AJ46T</code></li>
<li>Leave a comment with one reason why you would like to win this book. Be sure you enter a valid email address so we can reach you if you win.</li>
<li>That's it, we'll announce the winner a week or two afterward!</li>
</ul>
<h2>Get the Book Now!</h2>
<p>Want to get started learning PHP the right way? Go ahead and <a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738'>grab the book now</a>, it's definitely a great book to have on hand!</p>
<div><a href='http://www.amazon.com/gp/product/1430224738?ie=UTF8&#038;tag=devtips-20&#038;linkCode=as2&#038;camp=1789&#038;creative=9325&#038;creativeASIN=1430224738' title='Get PHP For Absolute Beginners'><img alt="" src="http://dev-tips.com/post_img/php_absolute_get_now.png" title="Get PHP For Absolute Beginners Now!" class="aligncenter" width="369" height="454" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/php-for-absolute-beginners-reviewed-giveaway/feed</wfw:commentRss>
		<slash:comments>74</slash:comments>
		</item>
		<item>
		<title>5 Must Bookmark Websites for Web Developers</title>
		<link>http://dev-tips.com/featured/5-must-bookmark-websites-for-web-developers</link>
		<comments>http://dev-tips.com/featured/5-must-bookmark-websites-for-web-developers#comments</comments>
		<pubDate>Fri, 04 Dec 2009 22:46:45 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[Web Dev 101]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=667</guid>
		<description><![CDATA[We all have our favorite websites lined up in Google Reader, often, we don't get the time to go through as many of the sites and articles that we would like. However, there are some sites related to web development that are essential to keep up with. Today, we will go through 5 must bookmark [...]]]></description>
			<content:encoded><![CDATA[<p>We all have our favorite websites lined up in Google Reader, often, we don't get the time to go through as many of the sites and articles that we would like. However, there are some sites related to web development that are essential to keep up with. Today, we will go through 5 must bookmark websites for web developers.</p>
<p><span id="more-667"></span></p>
<h2>1. NETTUTS+ Web Development Tuts</h2>
<div class='tutorial_image'><a href='http://nettuts.com' title='NETTUTS Home'><img src='http://dev-tips.com/post_img/webdev_nettuts.png' alt='NETTUTS Screenshot' /></a></div>
<p><a href='http://nettuts.com' title='NETTUTS'>NETTUTS</a> is a popular web development web site with a new tutorial posted every day (except for weekends). Every tutorial is in depth and extremely well written, along with helpful images and/or video screencasts. All topics are covered.</p>
<h2 class='box demo'><a href='http://nettuts.com' title='NETTUTS'>Visit NETTUTS+</a></h2>
<h2>2. Gaya Design Blog</h2>
<div class='tutorial_image'><a href='http://www.gayadesign.com/' title='Gaya Design'><img src='http://dev-tips.com/post_img/webdev_gaya.png' alt='Gaya Design' /></a></div>
<p><a href='http://www.gayadesign.com/' title='Gaya Design'>Gaya Design Blog</a> is a blog run by fellow web developer and a good friend of mine, Gaya Kessler.  Gaya is an extremely talented designer and developer, who frequently posts nifty Javascript and CSS targeted articles. His blog's design is quite fun and interactive as well!</p>
<h2 class='box demo'><a href='http://www.gayadesign.com/' title='Gaya Design'>Visit Gaya Design</a></h2>
<h2>3. CSS-Tricks</h2>
<div class='tutorial_image'><a href='http://css-tricks.com/' title='CSS-Tricks'><img src='http://dev-tips.com/post_img/webdev_csstricks.png' alt='CSS-Tricks Screenshot' /></a></div>
<p><a href='http://css-tricks.com/' title='CSS-Tricks'>CSS-Tricks</a> is a web development website run by the talented web designer and friend of Dev-Tips, <a href='http://chriscoyier.net' title='Chris Coyier'>Chris Coyier</a>. CSS-Tricks focuses on, well, a lot of CSS and HTML tricks. CSS-Tricks also hosts a variety of extremely well done video screencasts. CSS-Tricks is a must have!</p>
<h2 class='box demo'><a href='http://css-tricks.com' title='CSS-Tricks'>Visit CSS-Tricks</a></h2>
<h2>4. David Walsh's Blog</h2>
<div class='tutorial_image'><a href='http://davidwalsh.name/' title='David Walsh'><img src='http://dev-tips.com/post_img/webdev_davidwalsh.png' alt='David Walsh Network' /></a></div>
<p><a href='http://davidwalsh.name/' title='David Walsh'>David Walsh</a> is a web developer and a core developer for the moo tools team. It should come as no surprise then that Davis covers <em>a lot</em> of Javascript techniques, including mootools and some jQuery.</p>
<h2 class='box demo'><a href='http://davidwalsh.name/' title='David Walsh'>Visit David Walsh's Blog</a></h2>
<h2>5. Snook.ca</h2>
<div class='tutorial_image'><a href='http://snook.ca/' title='Snook.ca'><img src='http://dev-tips.com/post_img/webdev_snooka.png' alt='Snook.ca Screenshot' /></a></div>
<p><a href='http://snook.ca/' title='Snook.ca'>Snook.ca</a> is a site run and maintained by Jonathan Snook. Jonathan is a very well known and well respected web developer and designer and for good reasons. Jonathan has a knack for coming up with elegant solutions to problems that every web developer faces.</p>
<h2 class='box demo'><a href='http://snook.ca/' title='Snook.ca'>Visit Snook.ca</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/5-must-bookmark-websites-for-web-developers/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How To Create Your First AJAX and PHP Contact Form</title>
		<link>http://dev-tips.com/featured/ajax-and-php-contact-form</link>
		<comments>http://dev-tips.com/featured/ajax-and-php-contact-form#comments</comments>
		<pubDate>Mon, 02 Nov 2009 12:38:24 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=586</guid>
		<description><![CDATA[You've been to websites that use them, a nice little AJAX contact form. AJAX is a great way to submit data without a page refresh and is a great tool for certain elements of a website, such as a contact form. So how do we go about doing so? Today, we will take it step [...]]]></description>
			<content:encoded><![CDATA[<p>You've been to websites that use them, a nice little AJAX contact form. AJAX is a great way to submit data without a page refresh and is a great tool for certain elements of a website, such as a contact form. So how do we go about doing so? Today, we will take it step by step and build your first AJAX and PHP contact form. We'll be using <a href='http://jquery.com' title='jQuery Javascript Library'>jQuery</a> and the popular <a href='http://code.google.com/p/php-email-address-validation/' title='Email Validation'>email validation code</a> found on google code (originally by AddedBytes) to help us out.</p>
<p><span id="more-586"></span><br />
<img src="http://dev-tips.com/wp-content/uploads/2009/11/php_ajax_form.png" alt="php_ajax_form" title="php_ajax_form" width="605" height="220" class="aligncenter size-full wp-image-635" /></p>
<h2 class='box demo'><a target='_blank' href='http://dev-tips.com/demo/ajax_contact_form/index.html' title='Live AJAX Contact Form Demo'>Live Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=4" title="Version 1.0 downloaded 1391 times" >Ajax_Contact_Form (1391) - 5.68 KB</a></div>
<h2>Folder Structure and Files</h2>
<p>Here is a brief overview of how we will setup our folders and files. If you are following along, you can go ahead and create all of these now, we'll get to them all one by one.</p>
<p>Below is the folder structure and files contained within:</p>
<ul>
<li><strong>assets</strong>
<ul>
<li><strong>css</strong>
<ul>
<li><em>style.css</em></li>
</ul>
</li>
<li><strong>js</strong>
<ul>
<li><em>ajax.js</em></li>
</ul>
</li>
<li><strong>php</strong>
<ul>
<li><em>contact-send.php</em></li>
<li><em>email-validator.php (will be downloaded and added later on)</em></li>
</ul>
</li>
<li>index.html</li>
</ul>
</ul>
<h2>HTML and Form Markup</h2>
<p>Now we need our HTML and form markup. We will try to keep it relatively simple.</p>
<h3>index.html</h3>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
	&lt;title&gt;Your First AJAX and PHP Contact Form - Live Demo&lt;/title&gt;

	&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;assets/js/ajax.js&quot;&gt;&lt;/script&gt;
	&lt;link rel=&quot;stylesheet&quot; type=&#039;text/css&#039; href=&#039;assets/css/style.css&#039; media=&#039;screen&#039; /&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;div id=&#039;wrap&#039;&gt;
		&lt;div id=&#039;header&#039;&gt;
			&lt;h1&gt;Get in touch with us...&lt;/h1&gt;
			&lt;h2&gt;Use the form below to try out the contact form.&lt;/h2&gt;
		&lt;/div&gt;

		&lt;form method=&#039;post&#039; action=&#039;./assets/php/contact-send.php&#039;&gt;
		&lt;fieldset&gt;
			&lt;legend&gt;Contact Us&lt;/legend&gt;
			&lt;label for=&#039;name&#039;&gt;Name (required)&lt;/label&gt;
				&lt;input id=&#039;form_name&#039; type=&#039;text&#039; name=&#039;name&#039; value=&#039;&#039; /&gt;
			&lt;label for=&#039;email&#039;&gt;Email (required)&lt;/label&gt;
				&lt;input id=&#039;form_email&#039; type=&#039;text&#039; name=&#039;email&#039; value=&#039;&#039; /&gt;
			&lt;label for=&#039;subject&#039;&gt;Subject&lt;/label&gt;
				&lt;input id=&#039;form_subject&#039; type=&#039;text&#039; name=&#039;subject&#039; value=&#039;&#039; /&gt;
			&lt;label for=&#039;message&#039;&gt;Message (required)&lt;/label&gt;
				&lt;textarea id=&#039;form_message&#039; rows=&#039;10&#039; cols=&#039;40&#039; name=&#039;message&#039; value=&#039;&#039;&gt;&lt;/textarea&gt;

			&lt;input id=&#039;form_submit&#039; type=&#039;submit&#039; name=&#039;submit&#039; value=&#039;Submit&#039; /&gt;

			&lt;p class=&#039;hide&#039; id=&#039;response&#039;&gt;&lt;/p&gt;

			&lt;div class=&#039;hide&#039;&gt;
				&lt;label for=&#039;spamCheck&#039;&gt;Do not fill out this field&lt;/label&gt;
				&lt;input name=&#039;spam_check&#039; type=&#039;text&#039; value=&#039;&#039; /&gt;
			&lt;/div&gt;
		&lt;/fieldset&gt;
		&lt;/form&gt;

	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Everything above should look pretty standard, you'll notice we have a weird input and label towards the bottom of the form. We will be using this as a very basic spam check later on. More on that in a bit.</p>
<p>Also take note we are importing jQuery, our soon to be created <code>ajax.js</code>, and our <code>style.css</code>.</p>
<h2>Styles</h2>
<p>I'll leave the styles up to you, here is the bare minimum. The only thing we really need to make sure is that we hide anything inside the div class of <code>hide</code>. Notice we have still typed<br />
<blockquote>Do not fill out this field</p></blockquote>
<p>. We've done so in the very rare chance someone is surfing without CSS, they will know to leave the field blank.</p>
<h3>style.css</h3>
<pre class="brush: css">
#wrap {
	margin:0 auto;
	width:960px;
}
.hide {
	display: none;
}
label {
	display:block;
}
input {
	display:block;
}
</pre>
<h2>The PHP Code</h2>
<p>If you need to brush up on your php skills check out <a href='http://dev-tips.com/featured/5-more-quality-sites-to-help-you-become-a-php-rockstar'>5 more quality sites to help you become a php rockstar</a></p>
<h3>A word about email validation</h3>
<p><strong>You will need to download a file before I go any further</strong>, you can download the <a href='http://code.google.com/p/php-email-address-validation/'>google email validation script here</a>.</p>
<p>Got it downloaded? Great! Name it <code>email-validator.php</code> and put it in your php folder you created.</p>
<p>Now, a word about email validation. It is tricky business to say the least. There are hundreds if not thousands of little tiny things to take into account. I recently wrote a blog post titled <a href='http://php-tips.net/validate-email-with-php-the-right-way/' title='The right way to validate an email address with php'>The right way to validate an email address with php.</a> In hindsight, thhe technique used in that post certainly works, but isn't without it's draw backs. <code>FILTER_VALIDATE_EMAIL</code> has known bugs and only runs on newer versions of php, so this isn't an option for a lot of people.</p>
<p>Tired yet? Bare with me.</p>
<p>This is where the <a href='http://code.google.com/p/php-email-address-validation/'>google code email validation script</a> we downloaded comes in to play. It <a href='http://www.addedbytes.com/php/email-address-validation/'>originally aired</a> on the well known site <a href='http://addedbytes.com'>AddedBytes.com</a>. It has since grown in popularity so much that it has been moved to google code where it has received hundreds of contributions from members around the world, all with a goal to build a very solid and quick email validation system.</p>
<p>In short, <strong>the google email validation script kicks ass and we are going to use it.</strong></p>
<h3>Back to the main php code</h3>
<p>Now is where we let the php do the heavy lifting. If you haven't already created your <code>contact-send.php</code> file, see the structure above and do so now.</p>
<p>I have left many comments in the code below, so be sure to read through them. I'll go through a few important bullet points after.</p>
<h3>contact-send.php</h3>
<p><small><strong>Editors note:</strong> Please ignore any duplicate <code>empty</code> function calls below, this is a known bug of the syntax highlighting plugin. You can always download the source files if you have any confusion.</small></p>
<pre class="brush: php">
&lt;?php
//Catch any errors while testing our script
//Remove when going live.
ini_set(&quot;display_errors&quot;, &quot;1&quot;);
error_reporting(E_ALL); 

//Ensures no one loads page and does simple spam check.
if(isset($_POST[&#039;name&#039;]) &amp;&amp; empty($_POST[&#039;spam_check&#039;]))
{
	//Include our email validator for later use
	require &#039;email-validator.php&#039;;
	$validator = new EmailAddressValidator();

	//Declare our $errors variable we will be using later to store any errors.
	$errors = array();

	//Setup our basic variables
	$input_name = strip_tags($_POST[&#039;name&#039;]);
	$input_email = strip_tags($_POST[&#039;email&#039;]);
	$input_subject = strip_tags($_POST[&#039;subject&#039;]);
	$input_message = strip_tags($_POST[&#039;message&#039;]);

	//We&#039;ll check and see if any of the required fields are empty.
	//We use an array to store the required fields.
	$required = array(&#039;Name field&#039; =&gt; &#039;name&#039;, &#039;Email field&#039; =&gt; &#039;email&#039;, &#039;Message field&#039; =&gt; &#039;message&#039;);

	//Loops through each required $_POST value
	//Checks to ensure it is not empty.
	foreach($required as $key=&gt;$value)
	{
		if(isset($_POST[$value]) &amp;&amp; $_POST[$value] !== &#039;&#039;)
		{
			continue;
		}
		else {
			$errors[] = $key . &#039; cannot be left blank&#039;;
		}
	}

	//Make sure the email is valid.
    if (!$validator-&gt;check_email_address($input_email)) {
           $errors[] = &#039;Email address is invalid.&#039;;
    }

	//Now check to see if there are any errors
	if(empty($errors))
	{

		//No errors, send mail using conditional to ensure it was sent.
		if(mail(&#039;fwdrew@gmail.com&#039;, &quot;Message from $input_name - $input_subject&quot;, $input_message, &quot;From: $input_email&quot;))
		{
			echo &#039;Your email has been sent.&#039;;
		}
		else
		{
			echo &#039;There was a problem sending your email.&#039;;
		}

	}
	else
	{

		//Errors were found, output all errors to the user.
		echo implode(&#039;&lt;br /&gt;&#039;, $errors);

	}
}
else
{
	die(&#039;Direct access to this page is not allowed.&#039;);
}
</pre>
<p>Read through the comments thoroughly, most of the code should explain itself.</p>
<p>A few notes:</p>
<ul>
<li>On lines 4-5, we turn error reporting on, this is always a good idea when testing. Remove these lines before going live.</li>
<li>On line 8, we ensure that no one loads the page directly, but also do a spam check. When spam bots hit a form they usually fill out <em>all</em> HTML input fields, regardless if they are hidden with css or not. Bots also usually fill in every single input field in hopes of successfully submitting the form. We make sure this field is empty before proceeding. This is a small and basic but effective method against some spam.</li>
<li>Lines 11-12 we include and initiate our email validation object.</li>
<li>Lines 29-39 check for any empty fields that are required.</li>
<li>Line 41-43 Check to see if the email is valid</li>
</ul>
<p>The rest should make sense.</p>
<p>Right now you have a complete and working contact form. Congratulations! However, we can make this even easier on the end user by using <a href='http://jquery.com' title='jQuery'>jQuery</a> and a simple AJAX request. jQuery is a Javascript library that allows you to easily do all kinds of cool things, such as <a href='http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing'>quick and easy font resizing</a> and <a href='http://dev-tips.com/featured/jquery-tip-animation-and-css-queuing' title='jQuery Animation'>animation</a>.</p>
<h2>The jQuery/Javascript</h2>
<p>Lets walk through the logic of what we want the jQuery code to do for us, before we start coding it. You'll find this will help you think things through and be more efficient.</p>
<ol>
<li>Include the jQuery library, we've done so in our <code>head</code> section of our HTML already.</li>
<li>When the form is clicked, ensure that we return false.</li>
<li>Setup our necessary variables holding our form values.</li>
<li>Show the user that work is being done (e.g. Loading...).</li>
<li>Make the AJAX request to our contact-send.php file with input fields as POST data.</li>
<li>Grab the response from the php file, and display it under the form, in the response element we have in our HTML page</li>
</ol>
<p>Again, I encourage you to go through each line of the code slowly, and read the comments.</p>
<h3>ajax.js</h3>
<pre class="brush: js">
$(function(){

	//Do what we need to when form is submitted.
	$(&#039;#form_submit&#039;).click(function(){

	//Setup any needed variables.
	var input_name = $(&#039;#form_name&#039;).val(),
		input_email = $(&#039;#form_email&#039;).val(),
		input_subject = $(&#039;#form_subject&#039;).val(),
		input_message = $(&#039;#form_message&#039;).val(),
		response_text = $(&#039;#response&#039;);
		//Hide any previous response text
		response_text.hide();

		//Change response text to &#039;loading...&#039;
		response_text.html(&#039;Loading...&#039;).show();

		//Make AJAX request
		$.post(&#039;http://dev-tips.com/demo/ajax_contact_form/assets/php/contact-send.php&#039;, {name: input_name, email: input_email, subject: input_subject, message: input_message}, function(data){
			response_text.html(data);
		});

		//Cancel default action
		return false;
	});

});
</pre>
<p>Obviously, you will want to change the address/location on line 19 to wherever your file is. The rest should be self explanatory.</p>
<h2>Works Without Javascript!</h2>
<p>Keep in mind a small amount of users wont surf with JavaScript enabled. This means anytime you use AJAX or JavaScript, you need to think about what will happen if JS is disabled. In our case, if JS is disabled, the form will refresh, be validated by php, and send the email if necessary. No worries for us <img src='http://dev-tips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Sit back and relax</h2>
<p>If you've been following along this whole time, you can relax and get some bacon now, you've just built a complete AJAX and PHP contact form from scratch!</p>
<p>Comments? Questions? Suggestions? Let me know what you think in the comments section below. And be sure to check out the live demo and/or download all of the files used in this tutorial.</p>
<div class='box sponsor'>
<h3>Usage</h3>
<p>You <strong>can</strong> use this script in any projects or websites you may have, you just cannot sell it as is. Yes, you can use it in commercial products, you just cannot download the script, and then turn around and sell it. Other than that go crazy!</p>
</div>
<h2 class='box demo'><a target='_blank' href='http://dev-tips.com/demo/ajax_contact_form/index.html' title='Live AJAX Contact Form Demo'>Live Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=4" title="Version 1.0 downloaded 1391 times" >Ajax_Contact_Form (1391) - 5.68 KB</a></div>
<h3>I love Chinese food!</h3>
<p>If you found this useful or plan on using this code, will you consider making a donation? I really just want some chicken fried rice.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="9372484">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"><br />
</form>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/ajax-and-php-contact-form/feed</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Get Your Recent Delicious Bookmarks Using PHP</title>
		<link>http://dev-tips.com/featured/get-your-recent-delicious-bookmarks-using-php</link>
		<comments>http://dev-tips.com/featured/get-your-recent-delicious-bookmarks-using-php#comments</comments>
		<pubDate>Tue, 27 Oct 2009 01:24:43 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=581</guid>
		<description><![CDATA[Salutations and good evening. If any of you are users of the delicious bookmarking system, then you may enjoy a new post we have published on PHP-Tips.net. The post goes through the process of retreiving your lastest bookmarks with php. Visit the post today! Also, don't forget to submit your 404 page to our 3 [...]]]></description>
			<content:encoded><![CDATA[<p>Salutations and good evening. If any of you are users of the delicious bookmarking system, then you may enjoy a new post we have published on <a href='http://php-tips.net' title='PHP Tips'>PHP-Tips.net</a>. The post goes through the process of retreiving your lastest bookmarks with php. <a href='http://php-tips.net/get-delicious-bookmarks-with-php/'>Visit the post today!</a> Also, don't forget to submit your 404 page to our <a href='http://dev-tips.com/featured/wordpress-and-html-theme-giveaway-three-premium-themes-up-for-grabs'>3 theme giveaway contest</a> for your chance to win!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/get-your-recent-delicious-bookmarks-using-php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress and HTML Theme Giveaway, Three Premium Themes Up For Grabs!</title>
		<link>http://dev-tips.com/featured/wordpress-and-html-theme-giveaway-three-premium-themes-up-for-grabs</link>
		<comments>http://dev-tips.com/featured/wordpress-and-html-theme-giveaway-three-premium-themes-up-for-grabs#comments</comments>
		<pubDate>Thu, 10 Sep 2009 08:58:17 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Server Side]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=544</guid>
		<description><![CDATA[We are happy to launch a wonderful WordPress theme giveaway today, with three premium themes up for grabs! Our good friends at ThemeForest and Themeforest author, MasterGreed, are giving away two premium WordPress themes and a spectacular HTML admin skin for a total of 3 themes! Keep reading for information on how to enter! 1st [...]]]></description>
			<content:encoded><![CDATA[<p>We are happy to launch a wonderful WordPress theme giveaway today, with three premium themes up for grabs! Our good friends at <a href='http://themeforest.net/?ref=creatingdrew'>ThemeForest</a> and Themeforest author, <a href='http://themeforest.net/user/Mastergreed'>MasterGreed</a>, are giving away two premium WordPress themes and a spectacular HTML admin skin for a total of 3 themes! Keep reading for information on how to enter!</p>
<p><span id="more-544"></span></p>
<h2>1<sup>st</sup> Place - <a href="http://themeforest.net/item/paraportica-clean-wordpress-theme/25165?ref=creatingdrew">Paraportica WordPress Theme</a></h2>
<div id="attachment_547" class="wp-caption alignnone" style="width: 610px"><a href="http://themeforest.net/item/paraportica-clean-wordpress-theme/25165?ref=creatingdrew"><img src="http://dev-tips.com/wp-content/uploads/2009/09/1_front-w600.jpg" alt="Paraportica Premium WordPress Theme" title="1_front-w600" width="600" height="441" class="size-full wp-image-547" /></a><p class="wp-caption-text">Paraportica Premium WordPress Theme</p></div><br />
<div id="attachment_556" class="wp-caption alignnone" style="width: 610px"><a href='http://themeforest.net/item/paraportica-clean-wordpress-theme/25165?ref=creatingdrew'><img src="http://dev-tips.com/wp-content/uploads/2009/09/2_comments-w600.jpg" alt="Paraportica WordPress Theme - Comments Section" title="2_comments-w600" width="600" height="441" class="size-full wp-image-556" /></a><p class="wp-caption-text">Paraportica WordPress Theme - Comments Section</p></div>
<p>Paraportica is a simple and clean theme for WordPress blog-like website, coming with 4 different colour styles: red, blue, green and coffee (with a lot of milk), and build-in Twitter stream.</p>
<p><strong>Features:</strong></p>
<ul>
<li>Valid  XHTML 1 .0 Transitional</li>
<li>4 colour styles</li>
<li>Widgetized sidebar</li>
<li>Build-in Twitter stream</li>
<li>Theme Options page to manage Twitter stream and change styles</li>
<li>Build-in, ‘Digg-like’  FAQ  markup <img title=";)" alt=";)" src="/images/smileys/wink.gif"/></li>
<li>Gravatar support for comments;</li>
<li>Ready for WordPress 2.7 comments;</li>
<li>Comments compatible with WordPress 2.6 too;</li>
</ul>
<h2>2<sup>nd</sup> - <a href="http://themeforest.net/item/north-hunters-wordpress-magazine/46645?ref=creatingdrew">North Hunters Premium WordPress Magazine</a></h2>
<div id="attachment_554" class="wp-caption alignnone" style="width: 600px"><a href="http://themeforest.net/item/north-hunters-wordpress-magazine/46645?ref=creatingdrew"><img src="http://dev-tips.com/wp-content/uploads/2009/09/1_front.jpg" alt="North Hunters Theme Previews" title="1_front" width="590" height="300" class="size-full wp-image-554" /></a><p class="wp-caption-text">North Hunters Theme Previews</p></div><br />
<div id="attachment_555" class="wp-caption alignnone" style="width: 610px"><a href="http://themeforest.net/item/north-hunters-wordpress-magazine/46645?ref=creatingdrew"><img src="http://dev-tips.com/wp-content/uploads/2009/09/3_dark-w600.jpg" alt="North Hunters - Dark Version" title="3_dark-w600" width="600" height="328" class="size-full wp-image-555" /></a><p class="wp-caption-text">North Hunters - Dark Version</p></div>
<p>North Hunters WordPress Magazine is a magazine-like theme for WordPress, with additional features like social media stream (with custom widget) and advanced images resize functionality. It works with WordPress 2.7 and 2.8 as well.</p>
<p><strong>Features</strong></p>
<ul>
<li>Custom theme options page, allowing you to manage the theme without dealing with code!</li>
<li>3 widget areas – sidebar and two on frontpage.</li>
<li>Dropdown menu</li>
<li>Custom Social Media Stream widget.</li>
<li>Using phpThumb() to manage image resizing.</li>
<li>Threaded comments, up to 10th depth!</li>
<li>Styling for build-in WordPress gallery!</li>
<li>Styling supports flickrRSS plugin, and widgets.</li>
<li><strong> NEW :</strong> 6 new styles, 7 styles in total!</li>
<li><strong> NEW :</strong> 3 custom widgets: Portoflio widget &#038; Video widget &#038; Site authors widget</li>
<li><strong> NEW :</strong> Tabbed featured section</li>
</ul>
<h2>3<sup>rd</sup> - <a href='http://themeforest.net/item/splash-manager/21263?ref=creatingdrew'>Splash Manager - Premium HTML Admin Skin</a></h2>
<div id="attachment_560" class="wp-caption alignnone" style="width: 610px"><a href='http://themeforest.net/item/splash-manager/21263?ref=creatingdrew'><img src="http://dev-tips.com/wp-content/uploads/2009/09/1_splashcoffee-w600.jpg" alt="Splash Manager - Admin Skin" title="1_splashcoffee-w600" width="600" height="301" class="size-full wp-image-560" /></a><p class="wp-caption-text">Splash Manager - Admin Skin</p></div>
<div id="attachment_561" class="wp-caption alignnone" style="width: 610px"><a href="http://themeforest.net/item/splash-manager/21263?ref=creatingdrew"><img src="http://dev-tips.com/wp-content/uploads/2009/09/3_splashclassic-w600.jpg" alt="Splash Manager - Alternate Blue Color Scheme" title="3_splashclassic-w600" width="600" height="301" class="size-full wp-image-561" /></a><p class="wp-caption-text">Splash Manager - Alternate Blue Color Scheme</p></div>
<p>Admin template coming with three different styles (coffee, classic &#038; green), with navigation supported by jQuery on the sidebar.</p>
<h2>How To Win</h2>
<p>This contest is all about having the most creative 404 page. To enter, simply follow the bullet points below:</p>
<ul>
<li><a href='http://themeforest.net/?ref=mastergreed'>Register for a ThemeForest account</a> if you haven't already. You must have a ThemeForest account to be eligible.</li>
<li>Submit your 404 page for a site you run. The website must be owned and run by yourself!</li>
<li><strong>Leave a link to your ThemeForest username AND your 404 page in the comments section.</strong></li>
</ul>
<p>After about two weeks or so of submissions, we will setup a poll on <a href='http://dev-tips.com' title='Dev-Tips'>Dev-Tips</a> to allow users to vote on the most creative 404 page that was submitted. The three winners will be given the themes above!</p>
<h2>Rules and Guidelines</h2>
<ul>
<li>You must leave both your ThemeForest username and your 404 page of your website in the comments section.</li>
<li>The 404 page submitted must be your own and the work must be done by you!</li>
<li>The contest will remain open to submissions for at least two weeks, and at our discretion we will setup a poll for voting.</li>
<li>Any attempt at cheating or anyone suspected of suspicious activity will be disqualified.</li>
</ul>
<h2>Special Thanks To...</h2>
<h3>ThemeForest</h3>
<div id="attachment_570" class="wp-caption alignnone" style="width: 610px"><a href="http://themeforest.net/?ref=creatingdrew"><img src="http://dev-tips.com/wp-content/uploads/2009/09/theme_forest_home.jpg" alt="ThemeForest" title="theme_forest_home" width="600" height="400" class="size-full wp-image-570" /></a><p class="wp-caption-text">ThemeForest</p></div>
<h3>MasterGreed</h3>
<div id="attachment_574" class="wp-caption alignnone" style="width: 610px"><a href="http://themeforest.net/user/Mastergreed/?ref=mastergreed"><img src="http://dev-tips.com/wp-content/uploads/2009/09/master_greed_port.jpg" alt="ThemeForest User - MasterGreed" title="master_greed_port" width="600" height="400" class="size-full wp-image-574" /></a><p class="wp-caption-text">ThemeForest User - MasterGreed</p></div>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/wordpress-and-html-theme-giveaway-three-premium-themes-up-for-grabs/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Website Review: Web Hosting Secrets Revealed</title>
		<link>http://dev-tips.com/featured/website-review-web-hosting-secrets-revealed</link>
		<comments>http://dev-tips.com/featured/website-review-web-hosting-secrets-revealed#comments</comments>
		<pubDate>Fri, 04 Sep 2009 01:13:56 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=530</guid>
		<description><![CDATA[Web hosting is a topic that every single web developer as had to deal with, probably more often than they would like to. We've all been frustrated by shady hosts, different hosting plans and layouts, and not to mention transferring domain names. There are sites out on the web however, who are dedicated to reviewing [...]]]></description>
			<content:encoded><![CDATA[<p>Web hosting is a topic that every single web developer as had to deal with, probably more often than they would like to. We've all been frustrated by shady hosts, different hosting plans and layouts, and not to mention transferring domain names. There are sites out on the web however, who are dedicated to reviewing and providing information about different web hosts. Today, we're going to have a look at one of these websites, <a href='http://www.webhostingsecretrevealed.com/' title='Web Hosting'>WebHostingSecretsRevealed</a>, and I am going to give my honest review of what I think about the website.</p>
<p><span id="more-530"></span></p>
<h2>Review Structure</h2>
<ol>
<li>First general thoughts.</li>
<li>Design review</li>
<li>Content review</li>
<li>Screenshots and resources</li>
<li>Final thoughts</li>
</ol>
<h2>First thoughts</h2>
<div id="attachment_535" class="wp-caption alignnone" style="width: 510px"><img src="http://dev-tips.com/wp-content/uploads/2009/09/whs_main.jpg" alt="WebHostingSecretRevealed Screenshot" title="whs_main" width="500" height="300" class="size-full wp-image-535" /><p class="wp-caption-text">WebHostingSecretRevealed Screenshot</p></div>
<p>When I first heard the domain name of WebHostingSecretsRevealed, I mistakenly thought that it was probably some shady website selling an ebook of some sorts. I couldn't have been more mistaken.</p>
<p>First of all, WebHostingSecrets revealed isn't trying to sell you anything, which I found to be a welcome relief in the world of hosting websites. Secondly, I was surprised when I turned off AdBlockPlus for WHS. Unlike many of its competitors websites, WHS has virtually no ads to speak of, no ads cluttering the sidebar, and certainly no annoying flashing ads. </p>
<p>To add on to that, I really enjoyed the initial design and overall mood provided by the layout of the site. It uses a combination of calm browns and muted grays that make reading and browsing on the site super easy on the eyes.</p>
<p>Lastly, I noticed on the sidebar there were quite a few articles from their blog that seemed intriguing. When I looked at a few of them, I realize I already had them bookmarked from quite some time ago. I rarely come across hosting websites with actual helpful content, and must give a tip of the hat to WebHostingSecrets for taking the time to write articles that actually help people. For example, <a href='http://www.webhostingsecretrevealed.com/web-hosting-knowledge/10-css-tutorials-that-will-make-your-website-looks-cool/'>10 must learn CSS tutorials</a> and <a href='http://www.webhostingsecretrevealed.com/blog-hosting/43-ways-to-make-your-blog-stand-out-from-the-crowd/'>43 ways to improve your blog</a> are both articles that provide quality content to its users.</p>
<p>In addition, one of it's most popular articles happens to be one of the most helpful. If you're looking for a quick guide to different web hosts, check out <a href='http://www.webhostingsecretrevealed.com/web-hosting-shopping/is-this-web-host-right-for-me-10-must-know-points/'>Is this web host right for me? 10 must know points.</a></p>
<h2>Design Review</h2>
<p>I mentioned earlier that I really enjoy the design of <a href='http://www.webhostingsecretrevealed.com'>WebHostingSecretRevealed</a>. I'm a big fan of not overdoing things and keeping them simple. The color palette and layout really help to achieve a simple and readable look.</p>
<p>The text in the footer is slightly small and difficult to read, so that would be one of my critiscisms of the design. Another design critique I'd like to see fixed is the RSS button moved up and made much more viewable on the page, right now it is way 'below the fold' and not so easy to find. I keep track of a lot of websites and like to be able to add them to my reader and browse whenever I like.</p>
<p>On a more positive note, I absolutely love the 'boxiness' of the whole design. It reminds me very much of the style of all the TUTS sites out there (nettuts, psdtuts etc), with it's sharp edges and attention to detail. Overall, I would have to rate te design at least an 8/10. A job very well done.</p>
<h2>Content Overview</h2>
<div id="attachment_536" class="wp-caption alignnone" style="width: 510px"><img src="http://dev-tips.com/wp-content/uploads/2009/09/whs_101.jpg" alt="WHS Article Screenshot" title="whs_101" width="500" height="300" class="size-full wp-image-536" /><p class="wp-caption-text">WHS Article Screenshot</p></div>
<p>Before we can go through the review of the sites content, we need to establish the purpose of the site and how relevant the content is to the purpose. The main purpose of the site is to provide users with information, good buys, and data on the different popular web hosts around the net.</p>
<p>I think this is an area where WHSR gets it right compared to a lot of other similar websites. The first thing one sees when loading the page is an easy to read table of some popular web hosts, their rating, and the link to the reviews where you can learn more. Doesn't get more simple than that.</p>
<p>On the same note, it would be nice if the table wasn't in such a generic review format. What do I mean by that? Well, it seems that a lot of companies take this hosting layout route with a table because it is very easy to read. I agree, it is easy to read, but it also a bit boring. Perhaps, the guys at <a href='http://webhostingsecretrevealed.com'>WHS</a> could use some custom icons or graphics to really spice up the effect of that main table.</p>
<p>In addition, WHS contains a blog and article list full of article that I actually want to read. I've listed some of my favorite articles above. One can really tell how much effort and time has gone into a websites article, and with WHS, the articles are well written and well researched. Hell, even if I wasn't looking for a hosting review, I would gladlu read the web development related articles.</p>
<h2>Screenshots and Resources</h2>
<div id="attachment_537" class="wp-caption alignnone" style="width: 510px"><img src="http://dev-tips.com/wp-content/uploads/2009/09/whs_table.jpg" alt="Table Screenshot" title="whs_table" width="500" height="300" class="size-full wp-image-537" /><p class="wp-caption-text">Table Screenshot</p></div><br />
<div id="attachment_538" class="wp-caption alignnone" style="width: 510px"><img src="http://dev-tips.com/wp-content/uploads/2009/09/whs_css.jpg" alt="WHS Article Screenshot" title="whs_css" width="500" height="300" class="size-full wp-image-538" /><p class="wp-caption-text">WHS Article Screenshot</p></div><br />
<div id="attachment_539" class="wp-caption alignnone" style="width: 510px"><img src="http://dev-tips.com/wp-content/uploads/2009/09/whs_host_review.jpg" alt="Host Review Screenshot" title="whs_host_review" width="500" height="300" class="size-full wp-image-539" /><p class="wp-caption-text">Host Review Screenshot</p></div>
<ul>
<li><a href='http://www.webhostingsecretrevealed.com/' title='WebHostingSecret Home Page'>WebHostingSecretRevealed</a></li>
<li><a href='http://www.webhostingsecretrevealed.com/web-hosting-shopping/is-this-web-host-right-for-me-10-must-know-points/' title='Is this web host right for me'>Is this web host right for me?</a></li>
<li><a href='http://www.webhostingsecretrevealed.com/web-hosting-knowledge/10-css-tutorials-that-will-make-your-website-looks-cool/' title='10 CSS Tutorials'>10 CSS Tutorials That Will Make Your Website Instantly Look Cool</a></li>
</ul>
<h2>Final Thoughts</h2>
<p>I really do think that WebHostingSecretRevealed is one of the few web hosting review companies that is doing it the right way. Minimal ads, no spam, helpful blog content, easy to find reviews, and a lovely design. You can't really ask for much more.</p>
<p>Though I usually don't need too much advice when it comes to web host I will be using and do recommend WebHostingSecretRevealed if you are in need of quality reviews without the crap.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/website-review-web-hosting-secrets-revealed/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Creating a Relative Time Function</title>
		<link>http://dev-tips.com/featured/creating-a-relative-time-function</link>
		<comments>http://dev-tips.com/featured/creating-a-relative-time-function#comments</comments>
		<pubDate>Mon, 17 Aug 2009 23:07:38 +0000</pubDate>
		<dc:creator>Vasili</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=516</guid>
		<description><![CDATA[You've seen this sort of thing everywhere. It's the new "web 2.0 thing" to do (at least I think so). Instead of displaying the time formatted a certain way no matter how recent it was, you can have "posts about X minutes ago". It gives a new twist to how dates are normally formatted. In [...]]]></description>
			<content:encoded><![CDATA[<p>You've seen this sort of thing everywhere. It's the new "web 2.0 thing" to do (at least I think so). Instead of displaying the time formatted a certain way no matter how recent it was, you can have <em>"posts about X minutes ago"</em>. It gives a new twist to how dates are normally formatted. In this tutorial I will show you how to create a simple PHP function that will accomplish this task for you.</p>
<p><span id="more-516"></span></p>
<div><div id="attachment_521" class="wp-caption alignnone" style="width: 610px"><img src="http://dev-tips.com/wp-content/uploads/2009/08/time_example.jpg" alt="PHP Time Example Image" title="time_example" width="600" height="170" class="size-full wp-image-521" /><p class="wp-caption-text">PHP Time Example Image</p></div></div>
<h3>Information You'll Need To Know</h3>
<p>PHP's dates and times are represented in seconds since January 1, 1970. This means that one minute is represented by 60, hours as 3600 and one day is 86400. No, I don't memorize those, why do you think they made calculators? <img src='http://dev-tips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Try and get familiar with PHP's <a href="http://us3.php.net/manual/en/function.date.php">date function</a> and <a href="http://dev-tips.com/featured/php-quick-tip-using-the-ternary-operator">ternary operators</a>. We'll be using both and they're two things you really should know about.</p>
<h3>Setup the Function</h3>
<p>For the sake of easy recognition I'll be naming the function <strong>relativeTime</strong>. It will accept three parameters: the time to check, the cutoff before the date is formatted, and the format for the date if it meets the limit. The default for the limit is one day which seems pretty fair.</p>
<p>After we have declared the function, we want to set $time to the current time if it's empty or something other than a string or number. However, if it's not empty and a string (like <em>"July 1, 1994 5:30"</em>) then apply <a href="http://us3.php.net/strtotime">strtotime</a> and convert it to something date() can work with. Finally, set a variable to store the current time, and one to hold the return value.</p>
<pre class="brush: php">
&lt;?php
function relativeTime($time = false, $limit = 86400, $format = &#039;g:i A M jS&#039;) {
if (empty($time) || (!is_string($time) &amp;&amp; !is_numeric($time))) $time = time();
elseif (is_string($time)) $time = strtotime($time);

$now = time();
$relative = &#039;&#039;;
}
?&gt;
</pre>
<h3>Is the $time right now?</h3>
<p>The next step is to check weather or not the passed time is the current time. You can change "now" to anything you want, but I thought it would work.</p>
<pre class="brush: php">
if ($time === $now) $relative = &#039;now&#039;;
</pre>
<h3>Or is it in the future?</h3>
<p>Then we'll want to check if the time is in the future. The only time I can see this happening is when you have posts that are scheduled to go up.</p>
<pre class="brush: php">
elseif ($time &gt; $now) $relative = &#039;in the future&#039;;
</pre>
<h3>Nope, it's in the past.</h3>
<p>After the two previous tests have failed, we are positive that the time to check is in the past. It's quite a chunk of code for this last part, but it pretty much repeats itself.</p>
<pre class="brush: php">
else {
$diff = $now - $time;

if ($diff &gt;= $limit) $relative = date($format, $time);
elseif ($diff &lt; 60) {
$relative = &#039;less than one minute ago&#039;;
} elseif (($minutes = ceil($diff/60)) &lt; 60) {
$relative = $minutes.&#039; minute&#039;.(((int)$minutes === 1) ? &#039;&#039; : &#039;s&#039;).&#039; ago&#039;;
} else {
$hours = ceil($diff/3600);
$relative = &#039;about &#039;.$hours.&#039; hour&#039;.(((int)$hours === 1) ? &#039;&#039; : &#039;s&#039;).&#039; ago&#039;;
}
}

return $relative;
</pre>
<p>First we need assign another variable that holds the difference (in seconds) between the date to check and now. If this new variable is greater than or equal to the limit parameter, set $relative to a formatted string. The next elseif statements checks to see if the difference is less than 60 seconds (one minute) and just sends back "less than one minute ago".</p>
<p>We then assign a new variable, $minutes, to the difference divided by 60 and rounded up. If $minutes is less than 60 (one hour), send back "X minute ago". If $minutes is not set to one, an s is appended to minute — this is done with the ternary operator.</p>
<p>The same process is used for the hours, only this time the difference is divided by 3600. Now does it make sense why I told you you will need to know that? <img src='http://dev-tips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>We finish the function by returning $realtive, which now contains one of six options.</p>
<h3>Conclusion</h3>
<pre class="brush: php">
&lt;?php
function relativeTime($time = false, $limit = 86400, $format = &#039;g:i A M jS&#039;) {
if (empty($time) || (!is_string($time) &amp;amp;&amp;amp; !is_numeric($time))) $time = time();
elseif (is_string($time)) $time = strtotime($time);

$now = time();
$relative = &#039;&#039;;

if ($time === $now) $relative = &#039;now&#039;;
elseif ($time &gt; $now) $relative = &#039;in the future&#039;;
else {
$diff = $now - $time;

if ($diff &gt;= $limit) $relative = date($format, $time);
elseif ($diff &lt; 60) {
$relative = &#039;less than one minute ago&#039;;
} elseif (($minutes = ceil($diff/60)) &lt; 60) {
$relative = $minutes.&#039; minute&#039;.(((int)$minutes === 1) ? &#039;&#039; : &#039;s&#039;).&#039; ago&#039;;
} else {
$hours = ceil($diff/3600);
$relative = &#039;about &#039;.$hours.&#039; hour&#039;.(((int)$hours === 1) ? &#039;&#039; : &#039;s&#039;).&#039; ago&#039;;
}
}

return $relative;
}
?&gt;
</pre>
<p>This may seem like a simple function but it's very helpful. I recently coded up a quick Twitter widget for my friend (because I told her the default one was crap...) and she wanted to have the dates in relative time. I was lucky to have already had this function saved on my computer. Hope you enjoyed and learned something new!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/creating-a-relative-time-function/feed</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>5 More Quality Sites to Help You Become a PHP Rockstar</title>
		<link>http://dev-tips.com/featured/5-more-quality-sites-to-help-you-become-a-php-rockstar</link>
		<comments>http://dev-tips.com/featured/5-more-quality-sites-to-help-you-become-a-php-rockstar#comments</comments>
		<pubDate>Wed, 15 Jul 2009 21:58:24 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=486</guid>
		<description><![CDATA[Not too long ago, we posted a popular article titled 5 quality sites to increase your knowledge of php. We received quite a positive response from this article and a few emails asking for more. That's all we needed to hear! Today we are back, and will be going over 5 more quality websites to [...]]]></description>
			<content:encoded><![CDATA[<p>Not too long ago, we posted a popular article titled <a href='http://dev-tips.com/featured/5-quality-sites-to-increase-your-knowledge-of-php' title='5 quality sites to increase your knowledge of php'>5 quality sites to increase your knowledge of php</a>. We received quite a positive response from this article and a few emails asking for more. That's all we needed to hear! Today we are back, and will be going over 5 more quality websites to help you become a php rockstar.</p>
<p><span id="more-486"></span></p>
<h2>0. phpro.org</h2>
<div class='tut_image'><a href='http://phpro.org'><img src='http://dev-tips.com/post_img/phpro.jpg' alt='PHPRO.org' /></a></div>
<p>I'm really surprised that I completely forgot to mention this site in our first php roundup. Though it takes a while for the author to publish a new post, the post quality found at <a href='http://phpro.org'>phpro.org</a> is second to none. These are hands down the most in depth, well explained, and well thought out articles on php I have read in a long time.</p>
<h2>1. PHP Developer</h2>
<div class='tut_image'><a href='http://phpdeveloper.org/' title='PHP Developer'><img src='http://dev-tips.com/post_img/php_developer.jpg' alt='PHP Developer' /></a></div>
<p><a href='http://phpdeveloper.org/'>PHP Developer</a> is your one stop shop for any php news, articles or tutorials. Many of the articles focus on advanced programming topics as well as new php releases, bug fixes, and different classes. If you are wanting to immerse yourself in the world of php, go ahead and subscribe to PHP Developer.</p>
<h2>2. Cal Evans Blog</h2>
<div class='tut_image'><a href='http://blog.calevans.com/' title='Cal Evans'><img src='http://dev-tips.com/post_img/cal_evans.jpg' alt='Cal Evans Blog' /></a></div>
<p>With a tagline of "Lint I find in my mind’s belly-button" it's hard not to like <a href='http://blog.calevans.com'>Cal Evans</a>. Cal is currently an independent computer consultant with a giant <a href='http://blog.calevans.com/resume-of-cal-evans/'>resume to back it up</a>. Cal has a lot of experience with Zend and php, as well as all kinds of different languages. His blog is always full of humour and interesting insights. I highly encourage you to check out the posts Cal has to offer.</p>
<h2>3. Derek Allard</h2>
<div class='tut_image'><a href='http://derekallard.com/'><img src='http://dev-tips.com/post_img/derek_allard.jpg' alt='Derek Allard' /></a></div>
<p><a href='http://derekallard.com/'>Derek Allard</a> is a programmer and one of the creators of the very popular php framework, <a href='http://codeigniter.com'>CodeIgniter</a>. Derek works at Ellis labs, whom have created such popular apps such as Bamboo Invoice. Derek frequently covers topics on php and the CodeIgniter framework, excellent for those who are jumping into the MVC style of php.</p>
<h2>4. David Walsh</h2>
<div class='tut_image'><a href='http://davidwalsh.name' title='David Walshs Blog'><img src='http://dev-tips.com/post_img/david_walsh.jpg' alt='David Walsh' /></a></div>
<p>Most of you are probably familiar with <a href='http://davidwalsh.name'>David Walsh</a> or his work. David is a fantastic web developer and in particularly, a Javascript guru. Even though a lot of his articles are on the topic of JS, many of them tend to incorporate the use of php, such as some nice AJAX techniques. David also has some very nice php classes and methods he has written over the years. If you are not reading Davids' blog, I highly encourage you to do so, David is as quality as developers come.</p>
<p>That'll do it for now, have I missed any sites that you all frequent for php help? What are some of your favorites? Let me know and I might include them in the next php roundup!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/5-more-quality-sites-to-help-you-become-a-php-rockstar/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Building your first blog from scratch with Frog CMS</title>
		<link>http://dev-tips.com/featured/building-your-first-blog-from-scratch-with-frog-cms</link>
		<comments>http://dev-tips.com/featured/building-your-first-blog-from-scratch-with-frog-cms#comments</comments>
		<pubDate>Mon, 13 Jul 2009 22:07:11 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Server Side]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=482</guid>
		<description><![CDATA[If you've ever wanted to learn how to setup a website using the sweet FrogCMS, now is your chance. In a new post on the ThemeForest blog, I go through each process step by step to get you up and running with the frog. We also look at things such as using snippets and making [...]]]></description>
			<content:encoded><![CDATA[<p>If you've ever wanted to learn how to setup a website using the sweet <a href='http://madebyfrog.com'>FrogCMS</a>, now is your chance. In a <a href='http://blog.themeforest.net/tutorials/building-a-blog-from-scratch-with-frog-cms/'>new post on the ThemeForest blog</a>, I go through each process step by step to get you up and running with the frog. We also look at things such as using snippets and making custom breadcrumb navigation.</p>
<p><span id="more-482"></span></p>
<h2 class='box demo'><a href='http://blog.themeforest.net/tutorials/building-a-blog-from-scratch-with-frog-cms/' title='Building your first blog with Frog CMS'>Visit Tutorial</a></h2>
<p>Let me know what you guys think of the article and if you would like more Frog CMS related topics covered in the future!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/building-your-first-blog-from-scratch-with-frog-cms/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
