<?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>The Tutorial Blog &#187; help</title>
	<atom:link href="http://www.thetutorialblog.com/tag/help/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetutorialblog.com</link>
	<description></description>
	<lastBuildDate>Wed, 07 Jul 2010 23:30:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<image>
<link>http://www.thetutorialblog.com</link>
<url>http://www.thetutorialblog.com/wp-content/plugins/maxblogpress-favicon/icons/favicon-28.ico</url>
<title>The Tutorial Blog</title>
</image>
		<item>
		<title>Web Hosting Providers: How to Utilize Your cPanel to Its Fullest</title>
		<link>http://www.thetutorialblog.com/websites/web-hosting-providers-how-to-utilize-your-cpanel-to-its-fullest/</link>
		<comments>http://www.thetutorialblog.com/websites/web-hosting-providers-how-to-utilize-your-cpanel-to-its-fullest/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 23:30:44 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[websites]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[cpanel]]></category>
		<category><![CDATA[cpanel admin]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[guest-post]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[hosting]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[website management]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=343</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	In your web hosting account, there is what you call the cPanel, short for Control Panel. This is where you will have access to everything you need to build your website and upload any necessary information and data. If you are a beginner to webhosting and cpanel use, then you should familiarize yourself with the [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/general/where-to-host-your-website/' rel='bookmark' title='Permanent Link: Where to host your website?'>Where to host your website?</a> <small>So you’ve successfully created a design for your website… the...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fwebsites%2Fweb-hosting-providers-how-to-utilize-your-cpanel-to-its-fullest%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fwebsites%2Fweb-hosting-providers-how-to-utilize-your-cpanel-to-its-fullest%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Web Hosting Providers: How to Utilize Your cPanel to Its Fullest" alt=" Web Hosting Providers: How to Utilize Your cPanel to Its Fullest" /><br />
			</a>
		</div>
<p><img class="alignleft size-full wp-image-334" title="cpanel_logo" src="http://www.thetutorialblog.com/wp-content/uploads/2010/07/cpanel_logo.jpg" alt="cpanel logo Web Hosting Providers: How to Utilize Your cPanel to Its Fullest" width="280" height="128" /></p>
<p>In your <a href="http://www.webhostingsearch.com/review/just-host.php#/JustPlan" target="_blank">web hosting</a> account, there is what you call the cPanel, short for Control Panel. This is where you will have access to everything you need to build your website and upload any necessary information and data. If you are a beginner to webhosting and cpanel use, then you should familiarize yourself with the cpanel before you start creating your website. This will allow you to be more efficient when it comes to making any changes to your site.  <a href="http://www.how-to-build-websites.com/" target="_blank"></a></p>
<p><a href="http://www.how-to-build-websites.com/" target="_blank">Designing</a>, internet hosting, and <a href="http://websitetips.com/planmanage/" target="_blank">managing a website</a> can be a challenging course of for individuals who want such a web site, but have never earlier than hosted one on the Internet. To assist in this process, making it smoother, extra intuitive, and more accessible for the potential web site owner, a management panel program named cPanel (based mostly on Unix) is now provided by some internet hosts as part of the hosting package. This system is written and marketed by an organization of the same name.<span id="more-343"></span></p>
<p>cPanel has a number of different units of controls, all of that are usable by way of any normal net browser. The controls included are those for resellers (who're buying the website area from an information heart and re-renting it to finish users), directors, and precise web site owners. The controls make modifying and administering the web site far simpler by automating some processes, and offering a graphical management interface that is intuitive and easy to recollect, slightly than command or scripting prompts.</p>
<p>The cPanel program supports lots of the functions utilized in building and sustaining web sites, similar to MySQL, PHP, Apache, Perl, and Bind. It additionally incorporates e-mail functionalities like POP3, SMTP, and IMAP. There are additionally many add-ons which can be used to allow support of other functions for website construction and administration - though these add-ons have to be bought from the cPanel company, and aren't obtainable as free downloads as so many add-ons are.</p>
<p>Hosting with cPanel gives those who are not highly expert in web site management a transparent, simple, intuitive interface that makes their efforts much smoother and more successful. Velocity of internet hosting and maintaining the web site are each elevated drastically by cPanel, especially since it should reduce the variety of calls that must be made to technical support. The interface consists of tutorial movies for the extra complicated operations, in addition to an on-display screen assist function, providing you with higher independence from tech help folks and saving certainly one of your most worthy sources - time.</p>
<p>As you can see, your cPanel controls most of your website and you need to be able to manage it in effective way. There are many things like scripts and add-ons that you need to be aware of. This way, when you decide to make changes to anything on your website whether it be design or coding, you are efficient with your time instead of trying to look up how to do something in your cPanel account hosting provider.</p>
<p>---</p>
<p>Kirsten Ramsburg is a senior editor of <a href="http://www.webhostingsearch.com" target="_blank">Webhostingsearch.com</a>.</p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/general/where-to-host-your-website/' rel='bookmark' title='Permanent Link: Where to host your website?'>Where to host your website?</a> <small>So you’ve successfully created a design for your website… the...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/websites/web-hosting-providers-how-to-utilize-your-cpanel-to-its-fullest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build a Twitter-like site with CodeIgniter and jQuery Part 2</title>
		<link>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/</link>
		<comments>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 19:58:15 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[build a social network]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[code igniter]]></category>
		<category><![CDATA[codeigniter series]]></category>
		<category><![CDATA[codeigniter tutorial]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[how to build a social network]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery series]]></category>
		<category><![CDATA[jquery tutorial]]></category>
		<category><![CDATA[php series]]></category>
		<category><![CDATA[series]]></category>
		<category><![CDATA[the tutorial blog]]></category>
		<category><![CDATA[twitter series]]></category>
		<category><![CDATA[twitter tutorial]]></category>
		<category><![CDATA[twitter-like tutorial]]></category>
		<category><![CDATA[wez pyke]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=268</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Don't forget to check out part 1 if you have no read it. In the second part of this 5 part tutorial series on how to build a Twitter-like website, we will be creating a signup form so that users can register to our website. We will be adding records to the database that we [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/' rel='bookmark' title='Permanent Link: Adding security to CodeIgniter forms with a custom library class'>Adding security to CodeIgniter forms with a custom library class</a> <small>The class that we are going to create within CI...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fbuild-a-twitter-like-site-with-codeigniter-and-jquery-part-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fbuild-a-twitter-like-site-with-codeigniter-and-jquery-part-2%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Build a Twitter like site with CodeIgniter and jQuery Part 2" alt=" Build a Twitter like site with CodeIgniter and jQuery Part 2" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/cijqt.jpg" alt="CodeIngiter + jQuery=twitter" title="CodeIngiter + jQuery=twitter" width="471" height="211" class="alignleft size-full wp-image-257" /><br />
Don't forget to check out <a href="http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/">part 1</a> if you have no read it.</p>
<p>In the second part of this 5 part tutorial series on how to build a Twitter-like website, we will be creating a signup form so that users can register to our website.</p>
<p>We will be adding records to the database that we created in part 1 and creating validation rules to make sure that the user didn't put any invalid data into the form.<br />
<span id="more-268"></span></p>
<h2>Change the base url</h2>
<p>Navigate to <em>ci_twitter->system->applications->config->config.php</em>.<br />
Change:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://example.com/&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To the path to where CodeIgniter is. On my machine it would be:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$config</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'base_url'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://tutorials:8888/ci_twitter/&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Create the controller</h2>
<p>We need to create a main controller for things such as the home page, sign up page, login page, etc. Go to <em>ci_twitter->system->application->controllers</em> then in the controllers folder create a file called main.php.</p>
<p>Inside our main controller we now need to define the class and the functions inside it.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> main <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> signup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signup'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> signin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>If we were to go to <em>http://localhost/ci_twitter/index.php/main/</em> then we will see a blank page.</p>
<h2>Create the views</h2>
<p>Before we can see anything we need to create a folder for the functions in our main controller. Go to <em>ci_twitter->system->application->views</em>. Inside the views folder create another folder called main. In the main folder we will create files for each function that we have in the main controller.</p>
<p>Create these files in the main folder we created:</p>
<ul>
<li>index.php</li>
<li>signup.php</li>
<li>signup_success.php</li>
<li>signin.php</li>
</ul>
<p>Go to index.php and enter Hello World. Now if you go to <em>http://localhost/ci_twitter/index.php/main/</em> you will see Hello World.</p>
<p>The next thing to do is to add a form and text fields so that people can input data. For the sign up page the html is done in the signup.php view file. The validation and processing is done in the main controller inside the signup function.</p>
<p>Add the following code to the signup.php view:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;h2&gt;Sign up&lt;/h2&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> validation_errors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> form_open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signup'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
Full name: &lt;input type=&quot;text&quot; name=&quot;name&quot; /&gt; &lt;br /&gt;
Username: &lt;input type=&quot;text&quot; name=&quot;username&quot; /&gt; &lt;br /&gt;
Password: &lt;input type=&quot;password&quot; name=&quot;password&quot; /&gt; &lt;br /&gt;
Email: &lt;input type=&quot;text&quot; name=&quot;email&quot; /&gt; &lt;br /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Create my account&quot; name=&quot;create&quot; /&gt;
&nbsp;
&lt;/form&gt;</pre></div></div>

<p>Then add this inside signup_success.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Your account was created, <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> anchor<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'login here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This is all that we need to do for the sign up view for now. Validation rules is what we will do next in the main controller for sign up.</p>
<h2>Validation</h2>
<p>When doing form validation all of the validation takes place inside of the controller. For now we will set basic validation rules for each field within the form.</p>
<p>In the main controller replace the code for the signup function with:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> signup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">helper</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[5]|max_length[50]|trim|xss_clean'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[5]|max_length[50]|trim|xss_clean'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Password'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[5]|max_length[50]|trim|xss_clean'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'required|min_length[5]|max_length[50]|valid_email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signup'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signup_success'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>If you go to the sign up page now you should see that all the validation code works like it should. Now we will add a model so that we can add the user to the users table.</p>
<h2>Create user model</h2>
<p>Go to the model folder and create a file called User_model.php.</p>
<p>Insert this code into the model:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> User_model <span style="color: #000000; font-weight: bold;">extends</span> Model <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> user_exists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">select</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">from</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">where</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_username'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">count_all_results</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> create_user<span style="color: #009900;">&#40;</span><span style="color: #000088;">$fullname</span><span style="color: #339933;">,</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'user_fullname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$fullname</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user_username'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user_email'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$email</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user_password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'users'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Now we need to load the User_model in the controller.<br />
Insert this code in the signup function:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">model</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'User_model'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We also need to add the user if the validation rules are passed:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">User_model</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">create_user</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'email'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'main/signup_success'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>Part 3</h2>
<p>In part 3 we will be creating a login page and functionality so that people can post messages.</p>
<h2>Download</h2>
<p><a href="http://bit.ly/c7ycMW">Download</a></p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/' rel='bookmark' title='Permanent Link: Adding security to CodeIgniter forms with a custom library class'>Adding security to CodeIgniter forms with a custom library class</a> <small>The class that we are going to create within CI...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Build a Twitter-like site with CodeIgniter and jQuery</title>
		<link>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/</link>
		<comments>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 15:39:07 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[build a social network]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[code igniter]]></category>
		<category><![CDATA[codeigniter series]]></category>
		<category><![CDATA[codeigniter tutorial]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[how to build a social network]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[jquery series]]></category>
		<category><![CDATA[jquery tutorial]]></category>
		<category><![CDATA[php series]]></category>
		<category><![CDATA[series]]></category>
		<category><![CDATA[the tutorial blog]]></category>
		<category><![CDATA[twitter series]]></category>
		<category><![CDATA[twitter tutorial]]></category>
		<category><![CDATA[twitter-like tutorial]]></category>
		<category><![CDATA[wez pyke]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=256</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	This tutorial will be the first of a five part series where we will built a social network site similar to Twitter from scratch. We will be using the CodeIgniter framework for the core of the website and jQuery for the effects. In this first part we will be configuring CodeIgniter to display everything correctly [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-cakephp-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CakePHP and jQuery'>Twitter-like pagination using CakePHP and jQuery</a> <small>I have already done this tutorial with CodeIgniter and jQuery...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fbuild-a-twitter-like-site-with-codeigniter-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fbuild-a-twitter-like-site-with-codeigniter-and-jquery%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Build a Twitter like site with CodeIgniter and jQuery" alt=" Build a Twitter like site with CodeIgniter and jQuery" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/cijqt.jpg" alt="CodeIngiter + jQuery=twitter" title="CodeIngiter + jQuery=twitter" width="471" height="211" class="alignleft size-full wp-image-257" /></p>
<p>This tutorial will be the first of a five part series where we will built a social network site similar to <a href="http://www.twitter.com">Twitter</a> from scratch. We will be using the <a href="http://www.codeigniter.com">CodeIgniter</a> framework for the core of the website and <a href="http://www.jquery.com">jQuery</a> for the effects. In this first part we will be configuring CodeIgniter to display everything correctly and we will also set up a database and connect to it.</p>
<p><span id="more-256"></span></p>
<h2>Download and configure</h2>
<p>Download the <a href="http://www.codeigniter.com">CodeIgniter</a> framework from their website. We don't need to download anything for jQuery because we will be loading it directly from Google as it's quicker to load.</p>
<p>Once you have downloaded the latest version of CodeIgniter from their website, unzip it and copy the files to your public_html folder or equivalent. Rename the CodeIgniter folder to ci_twitter.</p>
<p>Now if you go to http://localhost/ci_twitter you should see something similar to the image below.<br />
<img src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/ci.jpg" alt="ci Build a Twitter like site with CodeIgniter and jQuery" title="ci" width="650" height="458" class="alignleft size-full wp-image-261" /></p>
<h2>Database</h2>
<p>We now need configure a database to connect to CodeIgniter so that we can use it to insert and retrieve information. Go to phpMyAdmin or whatever you use for MySQL databases. Create a database called ci_twitter.</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">DATABASE</span> <span style="color: #008000;">`ci<span style="color: #008080; font-weight: bold;">_</span>twitter`</span> <span style="color: #000033;">;</span></pre></div></div>

<p>For now we are only going to create a table for the users, in another part we will create other tables when we need them.</p>
<p><strong>users table</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"> <span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">TABLE</span> <span style="color: #008000;">`ci<span style="color: #008080; font-weight: bold;">_</span>twitter`</span>.<span style="color: #008000;">`users`</span> <span style="color: #FF00FF;">&#40;</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>id`</span> <span style="color: #999900; font-weight: bold;">INT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #FF9900; font-weight: bold;">AUTO_INCREMENT</span> <span style="color: #990099; font-weight: bold;">PRIMARY KEY</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>fullname`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>username`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>email`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>password`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>protected<span style="color: #008080; font-weight: bold;">_</span>updates`</span> <span style="color: #999900; font-weight: bold;">TINYINT</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #990099; font-weight: bold;">DEFAULT</span> <span style="color: #008000;">'0'</span><span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>location`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>web`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">50</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span> <span style="color: #000033;">,</span>
<span style="color: #008000;">`user<span style="color: #008080; font-weight: bold;">_</span>bio`</span> <span style="color: #999900; font-weight: bold;">VARCHAR</span><span style="color: #FF00FF;">&#40;</span> <span style="color: #008080;">160</span> <span style="color: #FF00FF;">&#41;</span> <span style="color: #CC0099; font-weight: bold;">NOT</span> <span style="color: #9900FF; font-weight: bold;">NULL</span>
<span style="color: #FF00FF;">&#41;</span> <span style="color: #990099; font-weight: bold;">ENGINE</span> <span style="color: #CC0099;">=</span> MYISAM</pre></div></div>

<h2>Configure CodeIgniter</h2>
<p>Now that we have set up our database and have inserted a table we will configure CodeIgniter to connect to it.</p>
<p>Navigate to database.php by going to <em>ci_twitter -> system -> application -> config -> database.php</em>. From here enter the correct information for your database so that it connects.</p>
<p>We need to auto load the database library because we will be using it a lot.</p>
<p>Go to <em>autoload.php</em> in the same folder as <em>database.php</em>.</p>
<p>Change:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$autoload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'libraries'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$autoload</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'libraries'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'database'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The database library will now load every time without us having to put $this->load->library('database'); in every controller.</p>
<h2>End of Part 1</h2>
<p>This is the end of the first part of approximately five parts.</p>
<h2>Part 2</h2>
<p>Part 2 will be following tomorrow. In part 2 we will be creating a sign up so that we can add users to the database.</p>
<h2>Download</h2>
<p>You can download part one from <a href="http://bit.ly/91HSQ0">here</a></p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-cakephp-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CakePHP and jQuery'>Twitter-like pagination using CakePHP and jQuery</a> <small>I have already done this tutorial with CodeIgniter and jQuery...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deep Linking with jQuery</title>
		<link>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/</link>
		<comments>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 14:43:43 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[deep linking]]></category>
		<category><![CDATA[deep linking tutorial]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[how-to]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery help]]></category>
		<category><![CDATA[jquery tutorial]]></category>
		<category><![CDATA[the tutorial blog]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web 2.0]]></category>
		<category><![CDATA[wez pyke]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=243</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	You can view a demo and download the resources for this tutorial at the bottom of the post. Web 2.0 websites have a lot of Ajax functionality, some times when you load a new element of a page you may want the user to be able to click the back or forward button so that [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/php/php-gallery-with-no-page-reloads-using-jquery/' rel='bookmark' title='Permanent Link: PHP gallery with no page reloads using jQuery'>PHP gallery with no page reloads using jQuery</a> <small>For this tutorial we will be using the ImgBrowz0r class...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fdeep-linking-with-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fjquery%2Fdeep-linking-with-jquery%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Deep Linking with jQuery" alt=" Deep Linking with jQuery" /><br />
			</a>
		</div>
<p><img src="http://www.thetutorialblog.com/wp-content/uploads/2010/02/Screen-shot-2010-02-10-at-14.52.00.png" alt="jQuery" title="jQuery" width="263" height="79" class="alignleft size-full wp-image-251" /></p>
<p><em>You can view a demo and download the resources for this tutorial at the bottom of the post.</em></p>
<p>Web 2.0 websites have a lot of Ajax functionality, some times when you load a new element of a page you may want the user to be able to click the back or forward button so that they can see the previously loaded content. One method to add this function to a website is to use the <a href="http://www.asual.com/jquery/address/">jQuery Address</a> plugin with jQuery. </p>
<p><a href="http://www.asual.com/jquery/address/">jQuery Addres</a>s has 4 main <a href="http://www.asual.com/jquery/address/docs/">methods</a>; <strong>init</strong>, <strong>change</strong>, <strong>internalChange</strong>, <strong>externalChange</strong>. The <strong>init</strong> method is what is called when the plugin is initiated. The <strong>change</strong> method is called when the URL is changed, an element in the page is changed or either the forward or backward button is pressed. The change method has the combined functionality of <strong>internalChange</strong> and <strong>externalChange</strong>. The <strong>internalChange</strong> is only called when a hyperlink inside the page is clicked; <strong>externalChange</strong> is only called when the URL is changed or the backward or forward button is pressed. </p>
<p>To allow deep linking within your website the only two methods that are required is <strong>init</strong> and <strong>change</strong>, you can then use <strong>internalChange</strong> and <strong>externalChange</strong> wherever you may need them. <br />
<span id="more-243"></span></p>
<h2>Getting it to work</h2>
<p>The first thing that is required of course is that you download the file for <a href="http://www.asual.com/jquery/address/">jQuery Address</a>. When you have done this copy the <em>jquery.address-1.1.min.js</em> file into the same location as your index.html file. </p>
<p>Now we include jQuery and the jQuery Address plugin, put this inside the head tags in your html file:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.4.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;script src=&quot;jquery.address-1.1.min.js&quot;&gt;&lt;/script&gt;</pre></div></div>

<h2>The jQuery</h2>
<p>The next thing that we're going to do is create a function that will be called when a hyperlink is clicked so that we know what file to load and where to load it. We will call this function <strong>loadURL()</strong>, it will take one parameter named url.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> loadURL<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loadURL: &quot;</span> <span style="color: #339933;">+</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>We have console.log so that when we open up Firebug in Firefox we know which page is being requested. This is useful for debugging if there are any faults with the requested page loading. </p>
<p>We now set the jQuery Address event handlers so we know when to deep link an element within the page.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">address</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;init: &quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>What this code does is retrieves the href attribute from a hyperlink by matching the rel to a hyperlink. We also log when it should have changed so we can see this in Firebug.</p>
<p>The last bit of jQuery that we do will check when a link has been pressed and then call the <strong>loadURL()</strong> function that we created before.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    	loadURL<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This is what the head of your file should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html 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;TheTutorialBlog.com : jQuery Deep Linking&lt;/title&gt;
	&lt;script src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	google.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;jquery&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1.4.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
	&lt;script src=&quot;jquery.address-1.1.min.js&quot;&gt;&lt;/script&gt;
&nbsp;
&nbsp;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #009966; font-style: italic;">/*&lt;![CDATA[*/</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;document&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	    <span style="color: #003366; font-weight: bold;">function</span> loadURL<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;loadURL: &quot;</span> <span style="color: #339933;">+</span> url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
	    <span style="color: #006600; font-style: italic;">// Event handlers</span>
	    $.<span style="color: #660066;">address</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;init: &quot;</span> <span style="color: #339933;">+</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#area&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[rel=address:'</span> <span style="color: #339933;">+</span> event.<span style="color: #660066;">value</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    	console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;change&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
	    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    	loadURL<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009966; font-style: italic;">/*]]&gt;*/</span>
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;/head&gt;</pre></div></div>

<h2>The HTML</h2>
<p>The HTML for this is really basic stuff, we will create two hyperlinks that will load two separate files. We will also create a div element named area, this is where the files will be loaded.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;body&gt;
&nbsp;
&nbsp;
	&lt;a href=&quot;test1.html&quot; rel=&quot;address:/test1&quot;&gt;Test 1&lt;/a&gt; &lt;br /&gt;
	&lt;a href=&quot;test2.html&quot; rel=&quot;address:/test2&quot;&gt;Test 2&lt;/a&gt; &lt;br /&gt; &lt;br /&gt; &lt;br /&gt;
&nbsp;
	Load Area: &lt;br /&gt;
	&lt;div id=&quot;area&quot;&gt;&lt;/div&gt;
&nbsp;
&nbsp;
&lt;/body&gt;</pre></div></div>

<p>The name of the file that you want to load goes inside the <strong>href</strong> tag. You also need to include <em>address:/</em> inside <strong>rel</strong>. This is how jQuery Address knows what hyperlinks you want to deep link.</p>
<h2>Final words</h2>
<p>I hope this tutorial has been useful, please feel free to leave a comment or ReTweet this tutorial on Twitter.</p>
<h2>Demo and Download</h2>
<p><a href="http://bit.ly/aU5vcT">Demo</a><br />
<a href="http://bit.ly/c95Qwa">Download</a></p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/php/php-gallery-with-no-page-reloads-using-jquery/' rel='bookmark' title='Permanent Link: PHP gallery with no page reloads using jQuery'>PHP gallery with no page reloads using jQuery</a> <small>For this tutorial we will be using the ImgBrowz0r class...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding security to CodeIgniter forms with a custom library class</title>
		<link>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/</link>
		<comments>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:03:48 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[question]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=159</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	The class that we are going to create within CI will simply add a math question that the user will have to enter correctly to continue. This is useful to stop bots from mass submitting information to your forms. The class we are going to write is only very short and simple, but it will [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fadding-security-to-codeigniter-forms-with-a-custom-library-class%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fphp%2Fadding-security-to-codeigniter-forms-with-a-custom-library-class%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="Adding security to CodeIgniter forms with a custom library class" alt=" Adding security to CodeIgniter forms with a custom library class" /><br />
			</a>
		</div>
<p>The class that we are going to create within CI will simply add a math question that the user will have to enter correctly to continue. This is useful to stop bots from mass submitting information to your forms.</p>
<p>The class we are going to write is only very short and simple, but it will give you an idea of how to create classes for your own projects.</p>
<h2>Creating the new class</h2>
<p>First of all we need to create the file for the class, navigate to libraries then create a file called math_question.php.</p>
<p>All we are going to do within this class is generate two random numbers that will be added together.<br />
<span id="more-159"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> math_question <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> questionOne<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// generate a random number between 0 - 10</span>
		<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$num</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> questionTwo<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$num</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$num</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is all we will be doing for the code within the class.</p>
<h2>Using the class within a form</h2>
<p>To use this class in our controller we load it like so:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We will also be using form validation and sessions to check if the user has entered the correct answer.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We need to set questionOne and questionTwo in variables so we can assign them to a temporary flash session and because they will be passed into the view.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionOne</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionTwo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionOne</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionTwo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;What is <span style="color: #006699; font-weight: bold;">{$questionOne}</span> + <span style="color: #006699; font-weight: bold;">{$questionTwo}</span>?&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>To check that the answer that is wrote in is correct we use the callback method in our form validation to call a function that we create that will check the users input against the flash data.</p>
<p>This is how we set our form validation:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Math Question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'callback_math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Then we check if the validation has been executed:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact/form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now we need to create our function that is called upon validation of the form:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> math_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$correct_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$questionOne</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$questionTwo</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_answer</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$correct_answer</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your answer to the math question was incorrect'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This will check if what the user has input is correct against a temporary flash session.</p>
<p>Here is all of the controller code in full:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">class</span> Contact <span style="color: #000000; font-weight: bold;">extends</span> Controller <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> index<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form_validation'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">library</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionOne</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">math_question</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">questionTwo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionOne</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$questionTwo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;What is <span style="color: #006699; font-weight: bold;">{$questionOne}</span> + <span style="color: #006699; font-weight: bold;">{$questionTwo}</span>?&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_rules</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Math Question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'callback_math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">run</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">load</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact/form'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;success&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> math_question<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$user_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">input</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionOne</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionOne'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$questionTwo</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">session</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">flashdata</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'questionTwo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$correct_answer</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$questionOne</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$questionTwo</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$user_answer</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$correct_answer</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form_validation</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_message</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'math_question'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Your answer to the math question was incorrect'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Create the view</h2>
<p>The last thing we need to do is create the view. Goto views and create a folder called contact, within that folder create a file called form.php.</p>
<p>Here is the code for form.php</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> validation_errors<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> form_open<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contact'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
Name: &lt;input type=&quot;text&quot; name=&quot;name&quot; /&gt; &lt;br /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #000088;">$math_question</span><span style="color: #000000; font-weight: bold;">?&gt;</span> &lt;br /&gt;
Answer: &lt;input type=&quot;text&quot; name=&quot;math_question&quot; /&gt; &lt;br /&gt;
&lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Send!&quot; /&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">echo</span> form_close<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>On the first line we output the validation errors if there is any, on the second line we use the form helper to open the form tags and likewise for the bottom line where we close the form. $math_question is the variable that is passed in from the controller.</p>
<h2>Post your thoughts</h2>
<p>Let us know what you think of the tutorial and share your thoughts and contributions below in the comments.</p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/php/twitter-like-pagination-using-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Twitter-like pagination using CodeIgniter and jQuery'>Twitter-like pagination using CodeIgniter and jQuery</a> <small>If you use Twitter you'll notice that there is a...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Form Validation</title>
		<link>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/</link>
		<comments>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 20:38:47 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[Video Tutorials]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=82</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Create a form that requires the user to enter both a username and password. If the username field or password field is left blank then a message will be displayed. Related posts:Build a Twitter-like site with CodeIgniter and jQuery Part 2 Don't forget to check out part 1 if you have... jQuery Dropdown Suggestions For [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/jquery/jquery-dropdown-suggestions/' rel='bookmark' title='Permanent Link: jQuery Dropdown Suggestions'>jQuery Dropdown Suggestions</a> <small>For this tutorial we are going to create a drop...</small></li>
<li><a href='http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/' rel='bookmark' title='Permanent Link: Adding security to CodeIgniter forms with a custom library class'>Adding security to CodeIgniter forms with a custom library class</a> <small>The class that we are going to create within CI...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-form-validation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-form-validation%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="jQuery Form Validation" alt=" jQuery Form Validation" /><br />
			</a>
		</div>
<p>Create a form that requires the user to enter both a username and password. If the username field or password field is left blank then a message will be displayed.</p>
<p><object type="application/x-shockwave-flash" width="512" height="399" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" ><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://blip.tv/scripts/flash/showplayer.swf" /><param name="flashvars" value="init=http://blip.tv/play/AYGN4GwA" /><embed src="http://blip.tv/play/AYGN4GwA" type="application/x-shockwave-flash" width="512" height="399" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery-part-2/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery Part 2'>Build a Twitter-like site with CodeIgniter and jQuery Part 2</a> <small>Don't forget to check out part 1 if you have...</small></li>
<li><a href='http://www.thetutorialblog.com/jquery/jquery-dropdown-suggestions/' rel='bookmark' title='Permanent Link: jQuery Dropdown Suggestions'>jQuery Dropdown Suggestions</a> <small>For this tutorial we are going to create a drop...</small></li>
<li><a href='http://www.thetutorialblog.com/php/adding-security-to-codeigniter-forms-with-a-custom-library-class/' rel='bookmark' title='Permanent Link: Adding security to CodeIgniter forms with a custom library class'>Adding security to CodeIgniter forms with a custom library class</a> <small>The class that we are going to create within CI...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/video-tutorials/jquery-form-validation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery #1</title>
		<link>http://www.thetutorialblog.com/video-tutorials/jquery-1/</link>
		<comments>http://www.thetutorialblog.com/video-tutorials/jquery-1/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 22:45:40 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[Video Tutorials]]></category>
		<category><![CDATA[animate]]></category>
		<category><![CDATA[blip]]></category>
		<category><![CDATA[blip.tv]]></category>
		<category><![CDATA[effect]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=73</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	Learn how to use the animate function within the jQuery library to create an effect similar to the table of contents for the table of contents on codeigniter.com. Blip.tv Link Click to play Related posts:Deep Linking with jQuery You can view a demo and download the resources for... Build a Twitter-like site with CodeIgniter and [...]


Related posts:<ol><li><a href='http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/' rel='bookmark' title='Permanent Link: Deep Linking with jQuery'>Deep Linking with jQuery</a> <small>You can view a demo and download the resources for...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/jquery/10-awesome-jquery-tutorials-you-should-check-out/' rel='bookmark' title='Permanent Link: 10 Awesome jQuery Tutorials You Should Check Out'>10 Awesome jQuery Tutorials You Should Check Out</a> <small>jQuery is a great tool that everyone in web development...</small></li>
</ol>

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-1%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.thetutorialblog.com%2Fvideo-tutorials%2Fjquery-1%2F&amp;source=wezpyke&amp;style=normal&amp;service=bit.ly" height="61" width="50" title="jQuery #1" alt=" jQuery #1" /><br />
			</a>
		</div>
<p>Learn how to use the animate function within the jQuery library to create an effect similar to the table of contents for the table of contents on codeigniter.com. </p>
<p><a href="http://thetutorialblog.blip.tv/file/2296444/">Blip.tv Link</a></p>
<p><span id="more-73"></span></p>
<p><center>															<script type="text/javascript" src="http://blip.tv/scripts/pokkariPlayer.js?ver=2008010901"></script>					<script type="text/javascript" src="http://blip.tv/syndication/write_player?skin=js&#038;posts_id=2312660&#038;source=3&#038;autoplay=true&#038;file_type=flv&#038;player_width=1024&#038;player_height=768"></script>
<div id="blip_movie_content_2312660">					<a rel="enclosure" href="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" onclick="play_blip_movie_2312660(); return false;"><img title="Click to play" alt="Video thumbnail. Click to play" width="512" height="384" src="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv.jpg" border="0" title="Click to play" /></a>					<br />					<a rel="enclosure" href="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" onclick="play_blip_movie_2312660(); return false;">Click to play</a>					</div>
<p>										</center></p>


<p>Related posts:<ol><li><a href='http://www.thetutorialblog.com/jquery/deep-linking-with-jquery/' rel='bookmark' title='Permanent Link: Deep Linking with jQuery'>Deep Linking with jQuery</a> <small>You can view a demo and download the resources for...</small></li>
<li><a href='http://www.thetutorialblog.com/php/build-a-twitter-like-site-with-codeigniter-and-jquery/' rel='bookmark' title='Permanent Link: Build a Twitter-like site with CodeIgniter and jQuery'>Build a Twitter-like site with CodeIgniter and jQuery</a> <small>This tutorial will be the first of a five part...</small></li>
<li><a href='http://www.thetutorialblog.com/jquery/10-awesome-jquery-tutorials-you-should-check-out/' rel='bookmark' title='Permanent Link: 10 Awesome jQuery Tutorials You Should Check Out'>10 Awesome jQuery Tutorials You Should Check Out</a> <small>jQuery is a great tool that everyone in web development...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thetutorialblog.com/video-tutorials/jquery-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://blip.tv/file/get/Thetutorialblog-jQuery1652.mov" length="34276983" type="video/quicktime" />
<enclosure url="http://blip.tv/file/get/Thetutorialblog-jQuery1834.flv" length="32154787" type="video/x-flv" />
		</item>
		<item>
		<title>Creating a WordPress plugin</title>
		<link>http://www.thetutorialblog.com/php/creating-a-wordpress-plugin/</link>
		<comments>http://www.thetutorialblog.com/php/creating-a-wordpress-plugin/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 17:10:34 +0000</pubDate>
		<dc:creator>Wez Pyke</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Text Tutorials]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[makeuseof]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wp]]></category>

		<guid isPermaLink="false">http://www.thetutorialblog.com/?p=38</guid>
		<description><![CDATA[	<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
		<style>
	#code_div { border: 1px solid #DFF4B5; background-color: #F0FFD2; padding-left: 50px; padding:10px;}
	</style>
	
	