<?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"
	>

<channel>
	<title>refrsh.com</title>
	<atom:link href="http://refrsh.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://refrsh.com</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Fri, 03 Sep 2010 09:01:51 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>getting fit - the backstory&#8230;&#8230;</title>
		<link>http://refrsh.com/2009/08/getting-fit-the-backstory/</link>
		<comments>http://refrsh.com/2009/08/getting-fit-the-backstory/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 20:55:47 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[Fat Boy]]></category>

		<category><![CDATA[fatboy]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=24</guid>
		<description><![CDATA[So whats this all about?
For many years I trained and fenced three times a week and hot the gym daily - working in the gym helped greatly but the upshod of it all was that I was a (relatively) trim 12st 5lbs.
Enter 2 kids, wife and self employment - out goes the gym, out goes [...]]]></description>
			<content:encoded><![CDATA[<p>So whats this all about?</p>
<p>For many years I trained and fenced three times a week and hot the gym daily - working in the gym helped greatly but the upshod of it all was that I was a (relatively) trim 12st 5lbs.</p>
<p>Enter 2 kids, wife and self employment - out goes the gym, out goes the fencing and on go the pounds. So currently I am somewhere around 16st 10lbs and I have had enough.</p>
<p>Recently I took a huge step in my life and health by quitting smoking. After 25 years of smoking I went cold turkey with patches and finally did it. Unsurprisingly on went a few more pounds but hey - its not that I mind as I can do something about a few extra pounds; I cant do much about lung cancer!</p>
<p>So heres the plan&#8230;&#8230;</p>
<p>As an incentive I am going to chart my progress (or epic fail) online and in pictures to see just how I get on.</p>
<p>I desperately want to get back to fencing and competing on a national level and so I need to do this. So tomorrow is going to be day 1.</p>
<p>Photos up and belly out <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2009/08/getting-fit-the-backstory/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Vector art - Dave the Penguin freebie</title>
		<link>http://refrsh.com/2008/07/vector-art-dave-the-penguin-freebie/</link>
		<comments>http://refrsh.com/2008/07/vector-art-dave-the-penguin-freebie/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 15:46:45 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[artwork]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=18</guid>
		<description><![CDATA[PSD File included for free download. 
Have a play and be nice to Dave

<a href="http://refrsh.com/wp-content/uploads/2008/07/penguin.jpg"><img class="alignleft size-thumbnail wp-image-19" title="Dave the Penguin" src="http://refrsh.com/wp-content/uploads/2008/07/penguin-150x150.jpg" alt="Give Dave a Home" width="150" height="150" />Give Dave the penguin a good home!!</a>]]></description>
			<content:encoded><![CDATA[<p>I was playing around with some more vector work, (yes boss, I am working too!) and came up with a penguin who I have affectionately named Dave.</p>
<p>I am including the PSD file in with Dave in case anyone wants it to download and play with.</p>
<p>If you do decide to give Dave a new home, please drop me a line and let me know <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Dave&#8230;.<br />
</strong>Click for larger view.<strong><br />
</strong></p>
<p><a href="http://refrsh.com/wp-content/uploads/2008/07/penguin.jpg"><img class="alignleft size-thumbnail wp-image-19" title="Dave the Penguin" src="http://refrsh.com/wp-content/uploads/2008/07/penguin-150x150.jpg" alt="Give Dave a Home" width="150" height="150" /></a></p>
<p><a href="http://refrsh.com/wp-content/uploads/2008/07/penguin.zip">Here is the psd (zipped)</a></p>
<p>Give him a good home and look after him!</p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/vector-art-dave-the-penguin-freebie/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More Vector thingy&#8217;s</title>
		<link>http://refrsh.com/2008/07/more-vector-thingys/</link>
		<comments>http://refrsh.com/2008/07/more-vector-thingys/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 14:04:50 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[artwork]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=14</guid>
		<description><![CDATA[Some more of the green things in vector format - 3 more added for now]]></description>
			<content:encoded><![CDATA[<p>As promised here are a few more green things. There are also red ones which I will put on as well.</p>
<p>If anybody wants to take the PSD and do more with it then let me know and I will link it up <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>1/ I think I need a break&#8230;..</p>
<p><a href="http://refrsh.com/wp-content/uploads/2008/07/break_copy.jpg"><img class="alignleft size-thumbnail wp-image-15" title="break_copy" src="http://refrsh.com/wp-content/uploads/2008/07/break_copy-150x150.jpg" alt="I need a break....." width="150" height="150" /></a></p>
<p>2/ sad</p>
<p><a href="http://refrsh.com/wp-content/uploads/2008/07/sad.png"><img class="alignnone size-thumbnail wp-image-16" title="sad" src="http://refrsh.com/wp-content/uploads/2008/07/sad-150x150.png" alt="sad" width="150" height="150" /></a></p>
<p>3/ sleepy</p>
<p><a href="http://refrsh.com/wp-content/uploads/2008/07/sleepy.png"><img class="alignnone size-thumbnail wp-image-17" title="sleepy" src="http://refrsh.com/wp-content/uploads/2008/07/sleepy-150x150.png" alt="sleepy" width="150" height="150" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/more-vector-thingys/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Worpress 2.5 upload bug&#8230;..</title>
		<link>http://refrsh.com/2008/07/worpress-25-upload-bug/</link>
		<comments>http://refrsh.com/2008/07/worpress-25-upload-bug/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 09:04:08 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[bug]]></category>

		<category><![CDATA[upload]]></category>

		<category><![CDATA[wordpress 2.5]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=12</guid>
		<description><![CDATA[The Wordpress 2.5 image upload bug.
What worked for me :)]]></description>
			<content:encoded><![CDATA[<p>Whilst uploading an image I kept getting an error message:</p>
<p>HTTP ERROR:</p>
<p>crunching&#8230;</p>
<p>and the image wouldnt upload.</p>
<p>This appears to be a know bug and a few people have a few theories but the one that worked for me was to create an .htaccess file in the wp-admin folder and add:</p>
<pre>
<div class="codesnip-container" >&lt;IfModule mod_security.c&gt;
&lt;Files async-upload.php&gt;
SecFilterEngine Off
SecFilterScanPOST Off
&lt;/Files&gt;
&lt;/IfModule&gt;

to it.</div>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/worpress-25-upload-bug/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Vector Art</title>
		<link>http://refrsh.com/2008/07/vector-art/</link>
		<comments>http://refrsh.com/2008/07/vector-art/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 22:11:13 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[artwork]]></category>

		<category><![CDATA[art]]></category>

		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=10</guid>
		<description><![CDATA[Spikey vector artwork]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" src="http://ztweb.com/computersoftwear/validate.gif" alt="Validation" /> Validation?<br />
One of a range of vector images I did for T Shirts not so long ago. I still have some availble with different designs if anyone i sinterested <img src='http://refrsh.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/vector-art/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Snippet - custom captcha</title>
		<link>http://refrsh.com/2008/07/php-snippet-custom-captcha/</link>
		<comments>http://refrsh.com/2008/07/php-snippet-custom-captcha/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 21:23:29 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[snippets]]></category>

		<category><![CDATA[captcha]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=9</guid>
		<description><![CDATA[Need a quick and dirty captcha?

session_start&#40;&#41;;
&#160; &#160; &#160; &#160; $str = str_shuffle&#40;&#8216;abcdefghijklmnopqrstuvwxyz0123456789&#8242;&#41;;
&#160; &#160; &#160; &#160; $substr = substr&#40;$str, 0, 6&#41;;
&#160; &#160; &#160; &#160; $im = imagecreate&#40;60, 25&#41;;
&#160; &#160; &#160; &#160; // white background and blue text
&#160; &#160; &#160; &#160; $bg = imagecolorallocate&#40;$im, 255, 255, 255&#41;;
&#160; &#160; &#160; &#160; $textcolor = imagecolorallocate&#40;$im, 0, 0, 0&#41;;
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>Need a quick and dirty captcha?</p>
<div class="codesnip-container" >
<div class="codesnip"><a href="http://www.php.net/session_start"><span class="kw3">session_start</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$str</span> = <a href="http://www.php.net/str_shuffle"><span class="kw3">str_shuffle</span></a><span class="br0">&#40;</span><span class="st0">&#8216;abcdefghijklmnopqrstuvwxyz0123456789&#8242;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$substr</span> = <a href="http://www.php.net/substr"><span class="kw3">substr</span></a><span class="br0">&#40;</span><span class="re0">$str</span>, <span class="nu0">0</span>, <span class="nu0">6</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$im</span> = imagecreate<span class="br0">&#40;</span><span class="nu0">60</span>, <span class="nu0">25</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// white background and blue text</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$bg</span> = imagecolorallocate<span class="br0">&#40;</span><span class="re0">$im</span>, <span class="nu0">255</span>, <span class="nu0">255</span>, <span class="nu0">255</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$textcolor</span> = imagecolorallocate<span class="br0">&#40;</span><span class="re0">$im</span>, <span class="nu0">0</span>, <span class="nu0">0</span>, <span class="nu0">0</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// write the string at the top left</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; imagestring<span class="br0">&#40;</span><span class="re0">$im</span>, <span class="nu0">5</span>, <span class="nu0">2</span>, <span class="nu0">4</span>, <span class="re0">$substr</span>, <span class="re0">$textcolor</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// output the image</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Content-type: image/png&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; imagepng<span class="br0">&#40;</span><span class="re0">$im</span><span class="br0">&#41;</span>;</div>
</div>
<p> Should give you a simple image (but easily decipherable by OCR Readers )</p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/php-snippet-custom-captcha/feed/</wfw:commentRss>
		</item>
		<item>
		<title>blog for 1 day and get spammed&#8230;..?</title>
		<link>http://refrsh.com/2008/07/blog-for-1-day-and-get-spammed/</link>
		<comments>http://refrsh.com/2008/07/blog-for-1-day-and-get-spammed/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 20:07:08 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[Personal]]></category>

		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=8</guid>
		<description><![CDATA[spam, spam, spam]]></description>
			<content:encoded><![CDATA[<p>So 1 day into my blogging life and I have 5 spam messages already.</p>
<p>Askimet is now activated so lets see what happens&#8230;&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/blog-for-1-day-and-get-spammed/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Basic PHP, MySQL Login tutorial</title>
		<link>http://refrsh.com/2008/07/basic-php-mysql-login-tutorial/</link>
		<comments>http://refrsh.com/2008/07/basic-php-mysql-login-tutorial/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 19:35:21 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[Tutorials]]></category>

		<category><![CDATA[login]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[sessions]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=7</guid>
		<description><![CDATA[Alrighty then, here goes with the first of what I hope will be many tutorials.
This is a BASIC login script that uses a MySQL database to log someone in.

It is by no means a complete, secure, authorising system so please dont come back with things like; "<em>Your session security is rubbish</em>" or "<em>Why isnt this in full OO code?</em>" - It's a principle tutorial with working code done in a semi OOP/procedural fashion for the purposes of learning.

So here we go, most of the text is in the code - cut, paste and learn :)]]></description>
			<content:encoded><![CDATA[<p>Alrighty then, here goes with the first of what I hope will be many tutorials.<br />
This is a BASIC login script that uses a MySQL database to log someone in.</p>
<p>It is by no means a complete, secure, authorising system so please dont come back with things like; &#8220;<em>Your session security is rubbish</em>&#8221; or &#8220;<em>Why isnt this in full OO code?</em>&#8221; - It&#8217;s a principle tutorial with working code done in a semi OOP/procedural fashion for the purposes of learning.</p>
<p>So here we go, most of the text is in the code - cut, paste and learn <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><!--More--></p>
<p>1) Database sql file<br />
Create a database or if you have one already just run the following code:</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="coMULTI">/*<br />
SQLyog Community Edition- MySQL GUI v6.05<br />
Host - 5.1.24-rc-community : Database - spf<br />
*********************************************************************<br />
Server version : 5.1.24-rc-community<br />
*/</span></p>
<p>
<span class="coMULTI">/*!40101 SET NAMES utf8 */</span>;</p>
<p><span class="coMULTI">/*!40101 SET SQL_MODE=&#8221;*/</span>;</p>
<p><span class="coMULTI">/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */</span>;<br />
<span class="coMULTI">/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=&#8217;NO_AUTO_VALUE_ON_ZERO&#8217; */</span>;</p>
<p><span class="coMULTI">/*Table structure for table `members` */</span></p>
<p>CREATE TABLE `members` <span class="br0">&#40;</span><br />
&nbsp; `id` int<span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> AUTO_INCREMENT COMMENT <span class="st0">&#8216;members id&#8217;</span>,<br />
&nbsp; `username` varchar<span class="br0">&#40;</span><span class="nu0">12</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> COMMENT <span class="st0">&#8216;members username&#8217;</span>,<br />
&nbsp; `password` varchar<span class="br0">&#40;</span><span class="nu0">255</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> COMMENT <span class="st0">&#8216;members password&#8217;</span>,<br />
&nbsp; PRIMARY <a href="http://www.php.net/key"><span class="kw3">KEY</span></a> <span class="br0">&#40;</span>`id`<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE=InnoDB AUTO_INCREMENT=<span class="nu0">3</span> <span class="kw2">DEFAULT</span> CHARSET=latin1;</p>
<p><span class="coMULTI">/*Data for the table `members` */</span></p>
<p>insert&nbsp; into `members`<span class="br0">&#40;</span>`id`,`username`,`password`<span class="br0">&#41;</span> values <span class="br0">&#40;</span><span class="nu0">1</span>,<span class="st0">&#8217;spike&#8217;</span>,<span class="st0">&#8216;a60e7822190108e7bfa5015a3f57dea1&#8242;</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="st0">&#8216;doug&#8217;</span>,<span class="st0">&#8216;b07b89b1d596bc0d32cbabed34147efd&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/*Table structure for table `membersinfo` */</span></p>
<p>CREATE TABLE `membersinfo` <span class="br0">&#40;</span><br />
&nbsp; `id` int<span class="br0">&#40;</span><span class="nu0">12</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> AUTO_INCREMENT COMMENT <span class="st0">&#8216;record id NOT user&#8217;</span>,<br />
&nbsp; `usr_id` int<span class="br0">&#40;</span><span class="nu0">6</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> COMMENT <span class="st0">&#8216;member id&#8217;</span>,<br />
&nbsp; `realname` varchar<span class="br0">&#40;</span><span class="nu0">255</span><span class="br0">&#41;</span> NOT <span class="kw2">NULL</span> COMMENT <span class="st0">&#8216;members realname&#8217;</span>,<br />
&nbsp; PRIMARY <a href="http://www.php.net/key"><span class="kw3">KEY</span></a> <span class="br0">&#40;</span>`id`<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span> ENGINE=InnoDB AUTO_INCREMENT=<span class="nu0">3</span> <span class="kw2">DEFAULT</span> CHARSET=latin1;</p>
<p><span class="coMULTI">/*Data for the table `membersinfo` */</span></p>
<p>insert&nbsp; into `membersinfo`<span class="br0">&#40;</span>`id`,`usr_id`,`realname`<span class="br0">&#41;</span> values <span class="br0">&#40;</span><span class="nu0">1</span>,<span class="nu0">1</span>,<span class="st0">&#8216;Mike&#8217;</span><span class="br0">&#41;</span>,<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="nu0">2</span>,<span class="st0">&#8216;Doug&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/*!40101 SET SQL_MODE=@OLD_SQL_MODE */</span>;<br />
<span class="coMULTI">/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */</span>;</div>
</div>
<p>The Username/ Password combinations are:<br />
spike/spike<br />
doug/doug</p>
<p>File 1 - functions.php<br />
(remember - comments are in the code!)</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span></p>
<p><span class="coMULTI">/* Basic login using php and mysql<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** nothing clever or complicated <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Build mainly to demonstrate a login system<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** that anyone can follow<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Requirements:<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** PHP4+/PHP5+<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** MySQL database<br />
&nbsp; &nbsp; &nbsp; &nbsp; **<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span></p>
<p><span class="coMULTI">/* functions.php<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** This page is literally for the function that can<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** be used in the script more than once or need to be<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** called from different locations eg: login<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Also on this page are some basic congiuration items<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** as this file is included in other pages<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** <br />
&nbsp; &nbsp; &nbsp; &nbsp; ** session_start();<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** www.php.net/session_start<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Initialize session data<br />
&nbsp; &nbsp; &nbsp; &nbsp; **<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** ini_set(&quot;display_errors&quot;, 2);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** ERROR_REPORTING(E_ALL);<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** set up error reporting<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** www.php.net/manual/en/function.error-reporting.php<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p><span class="coMULTI">/* session handler<br />
&nbsp; &nbsp; ** Start session<br />
&nbsp; &nbsp; ** append with @ depending on server config */</span><br />
@<a href="http://www.php.net/session_start"><span class="kw3">session_start</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/* error handler<br />
&nbsp; &nbsp; ** set error reporting level to 0 to show no error, 2 to show */</span><br />
<a href="http://www.php.net/ini_set"><span class="kw3">ini_set</span></a><span class="br0">&#40;</span><span class="st0">&#8220;display_errors&#8221;</span>, <span class="nu0">2</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/error_reporting"><span class="kw3">ERROR_REPORTING</span></a><span class="br0">&#40;</span><span class="kw2">E_ALL</span><span class="br0">&#41;</span>;</p>
<p>
<span class="coMULTI">/* define some useful constants<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st0">&#8216;DB_USER&#8217;</span>, <span class="st0">&#8216;root&#8217;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st0">&#8216;DB_PASS&#8217;</span>, <span class="st0">&#8216;peanuts2&#8242;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st0">&#8216;DB_HOST&#8217;</span>, <span class="st0">&#8216;localhost&#8217;</span><span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/define"><span class="kw3">define</span></a><span class="br0">&#40;</span><span class="st0">&#8216;DB_BASE&#8217;</span>, <span class="st0">&#8217;spf&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/* database connection<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** connect to your MySQL database<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** using the constants above.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** <br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<a href="http://www.php.net/mysql_connect"><span class="kw3">mysql_connect</span></a><span class="br0">&#40;</span>DB_HOST, DB_USER, DB_PASS<span class="br0">&#41;</span>;<br />
<a href="http://www.php.net/mysql_select_db"><span class="kw3">mysql_select_db</span></a><span class="br0">&#40;</span>DB_BASE<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="coMULTI">/*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; function: login form<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** basic login form<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** nothing fancy <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span> loginForm<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="st0">&#8216;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fieldset&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;legend&gt;Please Login&lt;/legend&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;form name=&quot;loginForm&quot; id=&quot;loginForm&quot; method=&quot;post&quot; action=&quot;&quot;&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;label for=&quot;usr&quot;&gt;Username&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;text&quot; name=&quot;usr&quot; value=&quot;&quot; /&gt;&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;&lt;label for=&quot;psw&quot;&gt;Password&lt;/label&gt;&lt;br /&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;password&quot; name=&quot;psw&quot; value=&quot;&quot; /&gt;&lt;/p&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;button type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;SUBMIT&quot;&gt;Login&lt;/button&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;input type=&quot;hidden&quot; name=&quot;login&quot; value=&quot;1&quot;&gt; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/form&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/fieldset&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8216;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
<span class="coMULTI">/*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; function: login process<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** process the login form<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*/</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span> loginProcess<span class="br0">&#40;</span><span class="re0">$username</span>, <span class="re0">$password</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* never trust incoming data<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** sanitise it and escape it <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** basic cleaning&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** mysql_real_escape_string (www.php.net/mysql_real_escape_string)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** trim (www.php.net/trim)<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$username</span> = <a href="http://www.php.net/mysql_real_escape_string"><span class="kw3">mysql_real_escape_string</span></a><span class="br0">&#40;</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="re0">$username</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* using md5 for password security<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** if you are using plain password - stop it!<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** if you insist on using plain passwords then <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** comment/hash the line below<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$password</span> = <a href="http://www.php.net/md5"><span class="kw3">md5</span></a><span class="br0">&#40;</span><span class="re0">$password</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* Run the query to find a match in the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** selecting only the basic fields and <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** NOT using * <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** also using LIMIT 1 as there should only be one <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** result&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&#8220;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , username<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , password<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; members<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; username = &#8216;$username&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; password =&#8217;$password&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; limit 1 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* are there any rows returned <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** from the login query?&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** mysql_num_rows() returns the total number of rows<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** found by the query <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** So if there is a row <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span class="kw3">mysql_num_rows</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span> &gt; <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* assign a results handler to the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** returned fields.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rows</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* register some session variables<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** based on the database values */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_logged&#8217;</span><span class="br0">&#93;</span> = <span class="nu0">1</span>; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_id&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$rows</span><span class="br0">&#91;</span><span class="st0">&#8216;id&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_name&#8217;</span><span class="br0">&#93;</span> = <span class="re0">$rows</span><span class="br0">&#91;</span><span class="st0">&#8216;username&#8217;</span><span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* now that the basic values are registered<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** fire them off to the next page <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** using header(&quot;Location: nextPage.php&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8220;location: members.php&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* exit() as we dont want the <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** script to carry on */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* but what happens if there are no results<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** returned from the database?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** Make a polite error message<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$errorMsg</span> = <span class="st0">&#8216;&lt;p&gt;Sorry. Your details couldnt be found&lt;/p&gt;&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* and return that value to the script<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** for displaying */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$errorMsg</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>&nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p><span class="coMULTI">/*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; function: check auth<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; is the usr_logged variable present?<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; has the user logged in?&nbsp;<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*/</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span> checkAuth<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* is the SESSION usr_logged variable <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** anywhere? */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* if not - redirect them to somewhere they can login<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; **&nbsp; &nbsp; &nbsp; */</span>&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_logged&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Location: index.php&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">false</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* return true - not really needed but keeps things tidy! */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw2">true</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p><span class="coMULTI">/*&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; function: get member details<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; based on the usr_id session variable&nbsp; &nbsp; <br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;*/</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">function</span> getMemberDetails<span class="br0">&#40;</span><span class="re0">$id</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* query the database using the session usr_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** variable. Also left join the information table<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** to get the extra information<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$sql</span> = <a href="http://www.php.net/mysql_query"><span class="kw3">mysql_query</span></a><span class="br0">&#40;</span><span class="st0">&#8220;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;members.id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , members.username<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , members.password<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; , membersinfo.realname<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; from<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; members<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; left join<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; membersinfo<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; on<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; members.id=membersinfo.usr_id<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; members.id = $id&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#8220;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* for this tutorial there are no real details<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** but if you had another table with more<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** information such as address, postcode etc<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** you can use the same theory<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* assign a results handler as we did earlier<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** to handle the returning information */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$rows</span> = <a href="http://www.php.net/mysql_fetch_assoc"><span class="kw3">mysql_fetch_assoc</span></a><span class="br0">&#40;</span><span class="re0">$sql</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* note that $rows is an ARRAY and as such holds the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;** information like:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;** $rows['usrname']<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;** $rows['password']<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;** etc&#8230; */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="re0">$rows</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p><span class="kw2">?&gt;</span></div>
</div>
<p>File 2 - index.php</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/* include the functions file<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** so that we can use those functions<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="kw1">include</span><span class="br0">&#40;</span><span class="st0">&#8216;functions.php&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/* set up an empty variable that we can &#8216;fill&#8217;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** later in the script.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** defining it here avoids the error message&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Undefined index $whatever on line X&#8230;.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="re0">$msg</span> = <span class="st0">&#8221;</span>;</p>
<p><span class="coMULTI">/* Has the login form been sent?<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Check the $_POST global array for the hidden field<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** Using a hidden field as they will always be sent with a form<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** whereas the submit button wont always be there if the user hits<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** enter.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** NB: Not sure if that still holds true with modern browsers but its<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** a habit now <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;login&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* fill the $msg variable that we defined earlier with the<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** results of the login function */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$msg</span> = loginProcess<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;usr&#8217;</span><span class="br0">&#93;</span>, <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;psw&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p>
<span class="kw2">?&gt;</span><br />
&lt;!DOCTYPE HTML PUBLIC <span class="st0">&#8220;-//W3C//DTD HTML 4.01 Transitional//EN&#8221;</span> <span class="st0">&#8220;http://www.w3.org/TR/html4/loose.dtd&#8221;</span>&gt;<br />
&lt;html&gt;</p>
<p>&lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;meta http-equiv=<span class="st0">&#8220;content-type&#8221;</span> content=<span class="st0">&#8220;text/html; charset=iso-8859-1&#8243;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;Index.php&lt;/title&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;h1&gt;Index&lt;/h1&gt;<br />
<span class="kw2">&lt;?php</span> <br />
<span class="coMULTI">/* down to the nitty gritty now!<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** If the $msg variable is not equal to nothing<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** then echo it<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** It should only be full if the login failed&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$msg</span> != <span class="st0">&#8221;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$msg</span>;<br />
<span class="br0">&#125;</span><br />
<span class="coMULTI">/* basic setup&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** check if the session variable usr_logged is present<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** if it isnt then the user cant have logged in so <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** give them the login form<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span>!<a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_logged&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> loginForm<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <a href="http://www.php.net/md5"><span class="kw3">md5</span></a><span class="br0">&#40;</span><span class="st0">&#8216;doug&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="kw2">?&gt;</span><br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
</div>
<p>file 3 - members.php</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">&lt;?php</span><br />
<span class="coMULTI">/* include the functions file<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** so that we can use those functions<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="kw1">include</span><span class="br0">&#40;</span><span class="st0">&#8216;functions.php&#8217;</span><span class="br0">&#41;</span>;</p>
<p><span class="coMULTI">/* USR/MEMBER AUTH CHECK<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** so this is our members page so we dont want any Tom, Dick or Harry<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** looking at it so&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
checkAuth<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="coMULTI">/* if they have got to here, they should be logged in&#8230;..<br />
&nbsp; &nbsp; &nbsp; &nbsp; **/</span></p>
<p><span class="coMULTI">/* get the member details based on the usr_id held<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** in the SESSION.<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<span class="re0">$memberDetails</span> = getMemberDetails<span class="br0">&#40;</span><span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_id&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;</p>
<p>
<span class="coMULTI">/* if the login form is on this page<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** process it if it has been sent */</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;login&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$msg</span> = loginProcess<span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;usr&#8217;</span><span class="br0">&#93;</span>, <span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st0">&#8216;psw&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></p>
<p><span class="coMULTI">/* logging out */</span><br />
<span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/isset"><span class="kw3">isset</span></a><span class="br0">&#40;</span><span class="re0">$_GET</span><span class="br0">&#91;</span><span class="st0">&#8216;logout&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_logged&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/unset"><span class="kw3">unset</span></a><span class="br0">&#40;</span><span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/header"><span class="kw3">header</span></a><span class="br0">&#40;</span><span class="st0">&#8220;Location: index.php&#8221;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/exit"><span class="kw3">exit</span></a><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span><br />
<span class="kw2">?&gt;</span><br />
&lt;!DOCTYPE HTML PUBLIC <span class="st0">&#8220;-//W3C//DTD HTML 4.01 Transitional//EN&#8221;</span> <span class="st0">&#8220;http://www.w3.org/TR/html4/loose.dtd&#8221;</span>&gt;<br />
&lt;html&gt;</p>
<p>&lt;head&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;meta http-equiv=<span class="st0">&#8220;content-type&#8221;</span> content=<span class="st0">&#8220;text/html; charset=iso-8859-1&#8243;</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;members.php&lt;/title&gt;<br />
&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;h1&gt;Members&lt;/h1&gt;<br />
&lt;a href=<span class="st0">&#8220;?logout&#8221;</span>&gt;Logout&lt;/a&gt;<br />
<span class="kw2">&lt;?php</span> </p>
<p><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;Welcome back &#8216;</span>. <span class="re0">$_SESSION</span><span class="br0">&#91;</span><span class="st0">&#8216;usr_name&#8217;</span><span class="br0">&#93;</span>;</p>
<p><span class="coMULTI">/* $memberDetails holds the information returned from the function<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** that gets all the information from the database<br />
&nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
<a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;p&gt;Members Realname is&#8230;. &#8216;</span>. <span class="re0">$memberDetails</span><span class="br0">&#91;</span><span class="st0">&#8216;realname&#8217;</span><span class="br0">&#93;</span> .<span class="st0">&#8216;&lt;/p&gt;&#8217;</span>;</p>
<p><span class="kw2">?&gt;</span><br />
&lt;p&gt;That is really all there is to it <span class="kw1">as</span> a basic, bare bones login <a href="http://www.php.net/system"><span class="kw3">system</span></a>.&lt;br /&gt;&lt;br /&gt;<br />
It has minimal security so that is something to look at <a href="http://www.php.net/next"><span class="kw3">next</span></a> <span class="kw1">as</span> is Adding a user to the database.&lt;/p&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</div>
</div>
<p>It should be quite easy to follow butif you have any questions, please just ask <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/basic-php-mysql-login-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>format size</title>
		<link>http://refrsh.com/2008/07/format-size/</link>
		<comments>http://refrsh.com/2008/07/format-size/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 22:26:26 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[snippets]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[size]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=5</guid>
		<description><![CDATA[PHP Snippet for formatting byte size.]]></description>
			<content:encoded><![CDATA[<p>Snippet for formatting byte size.</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">function</span> formatSize<span class="br0">&#40;</span><span class="re0">$size</span>, <span class="re0">$round</span> = <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re0">$sizes</span> = <a href="http://www.php.net/array"><span class="kw3">array</span></a><span class="br0">&#40;</span><span class="st0">&#8216;B&#8217;</span>, <span class="st0">&#8216;kB&#8217;</span>, <span class="st0">&#8216;MB&#8217;</span>, <span class="st0">&#8216;GB&#8217;</span>, <span class="st0">&#8216;TB&#8217;</span>, <span class="st0">&#8216;PB&#8217;</span>, <span class="st0">&#8216;EB&#8217;</span>, <span class="st0">&#8216;ZB&#8217;</span>, <span class="st0">&#8216;YB&#8217;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="re0">$i</span>=<span class="nu0">0</span>; <span class="re0">$size</span> &gt; <span class="nu0">1024</span> &amp;&amp; <span class="re0">$i</span> &lt; <a href="http://www.php.net/count"><span class="kw3">count</span></a><span class="br0">&#40;</span><span class="re0">$sizes</span><span class="br0">&#41;</span> - <span class="nu0">1</span>; <span class="re0">$i</span>++<span class="br0">&#41;</span> <span class="re0">$size</span> /= <span class="nu0">1024</span>;<br />
&nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span><span class="re0">$size</span>,<span class="re0">$round</span><span class="br0">&#41;</span>.<span class="re0">$sizes</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span>;<br />
<span class="br0">&#125;</span></div>
</div>
<p>Usage:</p>
<div class="codesnip-container" >
<div class="codesnip">formatSize<span class="br0">&#40;</span><span class="st0">&#8216;12345&#8242;</span><span class="br0">&#41;</span>;</div>
</div>
<p>*********** UPDATE **********<br />
From LogicEarth at Sitepoint, an alternative method<br />
Cheers LE <img src='http://refrsh.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">function</span> fromBytes <span class="br0">&#40;</span> <span class="re0">$size</span>, <span class="re0">$place</span> = <span class="nu0">3</span>, <span class="re0">$iec</span> = <span class="kw2">true</span>, <span class="re0">$bits</span> = <span class="kw2">false</span> <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$messure</span> = <span class="st0">&#8216;KMGTPXZY&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$factor</span>&nbsp; = <span class="re0">$iec</span> ? <span class="nu0">1024</span> : <span class="nu0">1000</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$count</span>&nbsp; &nbsp;= <span class="nu0">0</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$bits</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$size</span> *= <span class="nu0">8</span>; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span> <span class="re0">$size</span> &gt;= <span class="re0">$factor</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$size</span> /= <span class="re0">$factor</span>; <span class="re0">$count</span>++;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$messure</span> = <span class="re0">$count</span> ? <span class="re0">$messure</span><span class="br0">&#91;</span> &#8211;<span class="re0">$count</span> <span class="br0">&#93;</span> . <span class="br0">&#40;</span> <span class="re0">$iec</span> ? <span class="st0">&#8216;i&#8217;</span> : <span class="st0">&#8221;</span> <span class="br0">&#41;</span> : <span class="st0">&#8221;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$messure</span> = !<span class="re0">$bits</span> ? <span class="re0">$messure</span> . <span class="st0">&#8216;B&#8217;</span> : <a href="http://www.php.net/strtolower"><span class="kw3">strtolower</span></a><span class="br0">&#40;</span> <span class="re0">$messure</span> <span class="br0">&#41;</span> . <span class="st0">&#8216;b&#8217;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <a href="http://www.php.net/round"><span class="kw3">round</span></a><span class="br0">&#40;</span> <span class="re0">$size</span>, <span class="re0">$place</span> <span class="br0">&#41;</span> . <span class="st0">&#8216; &#8216;</span> . <span class="re0">$messure</span>;<br />
<span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/format-size/feed/</wfw:commentRss>
		</item>
		<item>
		<title>debugger function</title>
		<link>http://refrsh.com/2008/07/debugger-function/</link>
		<comments>http://refrsh.com/2008/07/debugger-function/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 21:18:53 +0000</pubDate>
		<dc:creator>SpikeZ</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<category><![CDATA[snippets]]></category>

		<category><![CDATA[debugger]]></category>

		<guid isPermaLink="false">http://refrsh.com/?p=4</guid>
		<description><![CDATA[Debugger Function:

Wrote this for a small CMS to return a nicel formatted error string.
Accepts either a string or Array as the argument and cn debug superglobals as well

(POST, SESSION, GET, COOKIE et al)]]></description>
			<content:encoded><![CDATA[<p>Debugger Function:</p>
<p>Wrote this for a small CMS to return a nicel formatted error string.<br />
Accepts either a string or Array as the argument and cn debug superglobals as well</p>
<p>(POST, SESSION, GET, COOKIE et al)</p>
<div class="codesnip-container" >
<div class="codesnip"><span class="kw2">function</span> debugger<span class="br0">&#40;</span><span class="re0">$desc</span>=<span class="kw2">null</span>, <span class="re0">$what</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* if it&#8217;s an array, print_r for formatted output<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><span class="re0">$desc</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;b&gt;&#8217;</span>. <span class="re0">$desc</span> .<span class="st0">&#8216;&lt;/b&gt;&lt;br /&gt;&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span><span class="br0">&#40;</span><a href="http://www.php.net/is_array"><span class="kw3">is_array</span></a><span class="br0">&#40;</span><span class="re0">$what</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* give the formatting<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;pre&gt;&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/print_r"><span class="kw3">print_r</span></a><span class="br0">&#40;</span><span class="re0">$what</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="st0">&#8216;&lt;/pre&gt;&#8217;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="coMULTI">/* otherwise just print out the string<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ** */</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/echo"><span class="kw3">echo</span></a> <span class="re0">$what</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://refrsh.com/2008/07/debugger-function/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
