<?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>Tony Virelli - Web Developer - HTML, xHTML, PHP, MySQL, JavaScript&#187; PHP</title>
	<atom:link href="http://tonyvirelli.com/category/blog/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://tonyvirelli.com</link>
	<description>Tony Virelli - I share the information I have dealing with web design, technology, the internet and more</description>
	<lastBuildDate>Tue, 31 Jan 2012 14:57:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Simple Alternating Row Color with PHP!</title>
		<link>http://tonyvirelli.com/blog/simple-alternating-row-color-with-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-alternating-row-color-with-php</link>
		<comments>http://tonyvirelli.com/blog/simple-alternating-row-color-with-php/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 15:20:07 +0000</pubDate>
		<dc:creator>Tony Virelli</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[alternate]]></category>
		<category><![CDATA[alternating]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[row color]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=599</guid>
		<description><![CDATA[If you have ever do table data and want to alternate the row colors here is a super simple way to do that using PHP. First you need to declare your variables. So since we are doing Alternating Colors I will use $ac as my var. &#60;?php $ac = 0; ?&#62; Then in your &#60;tr&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>If you have ever do table data and want to alternate the row colors here is a super simple way to do that using PHP.<br />
<span id="more-599"></span><br />
First you need to declare your variables. So since we are doing <span style="text-decoration: underline;">A</span>lternating <span style="text-decoration: underline;">C</span>olors I will use $ac as my var.</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: #000088;">$ac</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Then in your &lt;tr&gt; tag it is as simple as adding this code:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;tr bgcolor=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ac</span><span style="color: #339933;">++%</span><span style="color:#800080;">2</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">&quot;#EBEBEB&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;#FFFFFF&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;</pre></div></div>

<p>Another way you could do it is to declare a class:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;tr class=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ac</span><span style="color: #339933;">++%</span><span style="color:#800080;">2</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>?<span style="color: #0000ff;">&quot;odd&quot;</span><span style="color: #339933;">:</span><span style="color: #0000ff;">&quot;even&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/blog/simple-alternating-row-color-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update Your Website Copyright With Some Simple PHP</title>
		<link>http://tonyvirelli.com/slider/update-your-website-copyright-with-some-simple-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=update-your-website-copyright-with-some-simple-php</link>
		<comments>http://tonyvirelli.com/slider/update-your-website-copyright-with-some-simple-php/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 07:00:24 +0000</pubDate>
		<dc:creator>Tony Virelli</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[copyright]]></category>
		<category><![CDATA[year]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=521</guid>
		<description><![CDATA[Ok, so every year web designers have the all dreaded task of updating the copyright on their designs. This isn&#8217;t so bad if you work for 1 company, but if you work for a design firm like I do and have tons of clients websites to update it can be a time eating task. So [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so every year web designers have the all dreaded task of updating the copyright on their designs. This isn&#8217;t so bad if you work for 1 company, but if you work for a design firm like I do and have tons of clients websites to update it can be a time eating task.<br />
<span id="more-521"></span><br />
So to fix this problem I wrote this super small, super easy bit of code. It&#8217;s nothing special, but it gets the job done.</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: #000088;">$startYear</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2010</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Enter the starting year of the copyright.</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$startYear</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$startYear</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</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: #b1b100;">echo</span> <span style="color: #000088;">$startYear</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>And for the function lovers</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;">function</span> updateCopyright<span style="color: #009900;">&#40;</span><span style="color: #000088;">$startYear</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$startYear</span> <span style="color: #339933;">&lt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$startYear</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</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: #b1b100;">echo</span> <span style="color: #000088;">$startYear</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>
//Usage: Copyright &amp;copy; <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> updateCopyright<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">2010</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> Company Name</pre></div></div>

<p>There ya go!</p>
<p>Isn&#8217;t making your life easier fun!? I sure think so!</p>
]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/slider/update-your-website-copyright-with-some-simple-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speeding Up MySQL with Indexes</title>
		<link>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=speeding-up-mysql-with-indexes</link>
		<comments>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/#comments</comments>
		<pubDate>Fri, 18 Dec 2009 14:30:05 +0000</pubDate>
		<dc:creator>John Hass</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=272</guid>
		<description><![CDATA[MySQL is an excellent database product and even though Oracle just bought out Sun, who bought out MySQL, Oracle still promised to keep up with MySQL patches and releases. (see more here)  This is great news for all us die hard MySQL and PHP guys, we no longer have to worry about giving up our [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL is an excellent database product and even though Oracle just bought out Sun, who bought out MySQL, Oracle still promised to keep up with MySQL patches and releases. (<a href="http://www.marketwatch.com/story/sun-climbs-after-oracle-presents-mysql-plan-2009-12-14">see more here</a>)  This is great news for all us die hard MySQL and PHP guys, we no longer have to worry about giving up our MySQL for something else (because you can have my PHP when you pry it from my cold dead fingers).  Though the question of the day is, when we get Millions of records how can we speed it up. Say for example I have a <em><strong>callrecord</strong></em> database that has a few things in it<br />
<span id="more-272"></span><br />
id|start_time|from_number|to_number|billsec</p>
<p>When I do a query by id everything is fast, but when I do a query by <strong><em>from_number</em></strong> everything is really slow, maybe even taking hours to complete. So lets create an index on the <em><strong>from_number</strong></em> to make it faster.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">CREATE INDEX full_from_number ON table_name (from_number);</pre></div></div>

<p>Now depending on the number of records you have this could take sometime. You can check on the status by opening another MySQL session and typing &#8220;show processlist&#8221;. This will show you what is currently going on in MySQL.  It may appear that your MySQL has froze, but it hasn&#8217;t. Be patient, I had a database take 18 hours before.</p>
<p>Why not index all fields?  This is a good question, but it is important to only index the fields that you perform a where on, creating an index, does slow the insert time some, but in my example with the <em><strong>callrecord</strong></em> database, I only filled it once a day and queried 100 times the next day, so creating extra indexes was a good thing to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/slider/speeding-up-mysql-with-indexes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Send An HTML &amp; Plain Text Email Using An SMTP Server With PHP &amp; PEAR</title>
		<link>http://tonyvirelli.com/slider/php-html-email-using-smtp/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-html-email-using-smtp</link>
		<comments>http://tonyvirelli.com/slider/php-html-email-using-smtp/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 09:31:51 +0000</pubDate>
		<dc:creator>Tony Virelli</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=164</guid>
		<description><![CDATA[You have to have PEAR installed. You can get more information at http://pear.php.net. &#60;?php include&#40;'Mail.php'&#41;; include&#40;'Mail/mime.php'&#41;; &#160; $text = 'Hello,\nHow are you doing?'; $html = 'Hello, How are you doing?'; &#160; $smtpinfo&#91;&#34;host&#34;&#93; = &#34;smtp.domain.com&#34;; $smtpinfo&#91;&#34;port&#34;&#93; = &#34;25&#34;; $smtpinfo&#91;&#34;auth&#34;&#93; = true; $smtpinfo&#91;&#34;username&#34;&#93; = &#34;SMTP USERNAME&#34;; $smtpinfo&#91;&#34;password&#34;&#93; = &#34;SMTP PASSWORD&#34;; &#160; $recipients = &#34;recipient@domain.com&#34;; $headers&#91;&#34;From&#34;&#93; = &#34;From [...]]]></description>
			<content:encoded><![CDATA[<p>You have to have PEAR installed. You can get more information at <a href="http://pear.php.net">http://pear.php.net</a>.</p>
<p><span id="more-164"></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: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Mail.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Mail/mime.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Hello,\nHow are you doing?'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Hello,
How are you doing?'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;host&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;smtp.domain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;port&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;25&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;auth&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SMTP USERNAME&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SMTP PASSWORD&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$recipients</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;recipient@domain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;From&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From Name &quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;To&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;recipient@domain.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;Subject&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Email Subject&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mime</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Mail_mime<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTXTBody</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setHTMLBody</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$html</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$body</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$headers</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mime</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">headers</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$headers</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=&amp;</span> <span style="color: #990000;">Mail</span><span style="color: #339933;">::</span><span style="color: #004000;">factory</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'smtp'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$smtpinfo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recipients</span><span style="color: #339933;">,</span> <span style="color: #000088;">$headers</span><span style="color: #339933;">,</span> <span style="color: #000088;">$body</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>PEAR<span style="color: #339933;">::</span><span style="color: #004000;">isError</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mail</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
&nbsp;
There was an error: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;
&nbsp;
&quot;</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: #b1b100;">echo</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;
&nbsp;
Message Sent To <span style="color: #006699; font-weight: bold;">$to</span>
&nbsp;
&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/slider/php-html-email-using-smtp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple PHP HTTP Authentication Page Protection</title>
		<link>http://tonyvirelli.com/slider/simple-php-authentication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-php-authentication</link>
		<comments>http://tonyvirelli.com/slider/simple-php-authentication/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 09:58:41 +0000</pubDate>
		<dc:creator>Tony Virelli</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[slider]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[password]]></category>

		<guid isPermaLink="false">http://tonyvirelli.com/?p=188</guid>
		<description><![CDATA[If you want to secure a web page, but don&#8217;t want to have integrate a database and don&#8217;t require unique usernames and passwords for each user this solution may work for you! &#60;?php function passwordProtect&#40;$username, $password&#41;&#123; if &#40; &#40; !isset&#40;$_SERVER&#91;'PHP_AUTH_USER'&#93;&#41; &#124;&#124; &#40; isset&#40;$_SERVER&#91;'PHP_AUTH_USER'&#93;&#41; &#38;&#38; $_SERVER&#91;'PHP_AUTH_USER'&#93; != $username &#41; &#41; &#38;&#38; &#40; !isset&#40;$_SERVER&#91;'PHP_AUTH_PW'&#93;&#41; &#124;&#124; &#40; isset&#40;$_SERVER&#91;'PHP_AUTH_PW'&#93;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to secure a web page, but don&#8217;t want to have integrate a database and don&#8217;t require unique usernames and passwords for each user this solution may work for you!<br />
<span id="more-188"></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;">function</span> passwordProtect<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</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: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>
<span style="color: #009900;">&#40;</span>
<span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span>
<span style="color: #009900;">&#40;</span>
<span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_USER'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$username</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
<span style="color: #009900;">&#40;</span>
<span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span>
<span style="color: #009900;">&#40;</span>
<span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
<span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'PHP_AUTH_PW'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #000088;">$password</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'WWW-Authenticate: Basic realm=&quot;Login&quot;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http/1.0 401 Unauthorized'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Please Login to continue.'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</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>Then to use the code simply echo the function</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> passwordProtect<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://tonyvirelli.com/slider/simple-php-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

