<?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>PHP Tutorials - Crivion's Blog</title>
	<atom:link href="/phpblog/feed/" rel="self" type="application/rss+xml" />
	<link>http://crivionweb.com/phpblog</link>
	<description>PHP tutorials - Examples of the most usefull scripts</description>
	<pubDate>Thu, 18 Dec 2008 13:30:02 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>PHP Tutorial : How to create a captcha image</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-how-to-create-a-captcha-image/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-how-to-create-a-captcha-image/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 13:30:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

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

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

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

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

		<category><![CDATA[security code]]></category>

		<category><![CDATA[security image]]></category>

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

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=38</guid>
		<description><![CDATA[Hi,
Are you tired of receiving spam messages from your contact forms or unwanted posts, robot accounts on your membership website? If yes, the solution is to create a php security image called captcha. That&#8217;s the best solution to secure your web forms, etc. For creating a captcha security code you need to have GD-library installed [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
Are you tired of receiving spam messages from your contact forms or unwanted posts, robot accounts on your membership website? If yes, the solution is to create a php security image called captcha. That&#8217;s the best solution to secure your web forms, etc. For creating a captcha security code you need to have GD-library installed and active on your webhost, but, most of the shared webhosts have this library installed. Here is the captcha code :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//The first step is to start a php session calling the special <span class="phpFunctionKeyword">function</span>
</span><span class="phpFunction">session_start</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//The seccond step is to generate a string randomly using <span class="phpFunction">rand</span> <span class="phpFunctionKeyword">function</span>
</span><span class="phpComment">//I<span class="phpString">'ll choose to get a random number <span class="phpNumber">6</span> numbers in length
</span>$randomcode <span class="phpOperator">=</span> <span class="phpFunction">rand</span><span class="phpOperator">(</span><span class="phpNumber">0</span>, 999999<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Now we need a background image to write the random number to it
</span>$captchafromimage <span class="phpOperator">=</span> <span class="phpFunction">imagecreatefrompng</span><span class="phpOperator">(</span><span class="phpString">"captcha.png"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Setting font color
</span>$color <span class="phpOperator">=</span><span class="htmlText"> ImageColorAllocate </span><span class="phpOperator">(</span>$captchafromimage, 50, 50, 50<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Ta da, here we are, writing the random generated code to the image
</span><span class="phpFunction">imagestring</span><span class="phpOperator">(</span>$captchafromimage, <span class="phpNumber">6</span>, 50, <span class="phpNumber">2</span>, $randomcode, $color<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Now the random number is coded into <span class="phpFunction">md5</span> secure format
</span><span class="phpComment">//and stored it into a session name to be able to validate
</span><span class="phpComment">//it in the future
</span><span class="phpScriptVar">$_SESSION</span><span class="phpOperator">[</span>'</span><span class="htmlText">randomcode</span><span class="phpString">'<span class="phpOperator">]</span> <span class="phpOperator">=</span> <span class="phpFunction">md5</span><span class="phpOperator">(</span>$randomcode<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Set up headers
</span><span class="phpFunction">header</span><span class="phpOperator">(</span><span class="phpString">"Content-type<span class="phpOperator">:</span> image/png"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Finally, let'</span>s show up the captcha image generated
</span><span class="phpFunction">imagepng</span><span class="phpOperator">(</span>$captchafromimage<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>You will need a background PNG image which you can download here (right click -> Save as)<br />
<img src="/phpblog/wp-content/themes/default/images/captcha.png" alt="captcha image" /><br />
Here is the captcha result :<br />
<img src="/phpblog/wp-content/themes/default/images/captcha.php" alt="php captcha" /></p>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-how-to-create-a-captcha-image/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : How to show visitor&#8217;s IP address</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-how-to-show-visitor-ip-address/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-how-to-show-visitor-ip-address/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 12:46:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

		<category><![CDATA[get ip]]></category>

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

		<category><![CDATA[ip address]]></category>

		<category><![CDATA[php ip]]></category>

		<category><![CDATA[show ip address]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=35</guid>
		<description><![CDATA[Hi,
In this &#8220;php tutorial&#8221; I will teach you guys how to show your users their IP address with only one line of code.

&#60;?php

print "YOUR IP ADDRESS IS : $_SERVER[REMOTE_ADDR]";
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
In this &#8220;php tutorial&#8221; I will teach you guys how to show your users their IP address with only one line of code.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="htmlText">
print </span><span class="phpString">"YOUR IP ADDRESS IS <span class="phpOperator">:</span> <span class="phpScriptVar">$_SERVER</span><span class="phpOperator">[</span><span class="htmlText">REMOTE_ADDR</span><span class="phpOperator">]</span>"</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-how-to-show-visitor-ip-address/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : Random Banner Rotator</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-random-banner-rotator/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-random-banner-rotator/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 11:18:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

		<category><![CDATA[Banner Rotator]]></category>

		<category><![CDATA[php Banner Rotator]]></category>

		<category><![CDATA[Random Banner Rotator]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=29</guid>
		<description><![CDATA[Hi,
In this php tutorial you will learn how to build a random image banner rotator. Basically, it&#8217;s the same as the link rotator, we build a php array with images wanted to rotate, then we&#8217;ll apply the rand() php function.

&#60;?php
$banners = array("path/img1.jpg", "path/img2.gif");
$max = sizeof($banners);
$rand = rand(0, $max);
print $banners[$rand];
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>In this php tutorial you will learn how to build a random image banner rotator. Basically, it&#8217;s the same as the link rotator, we build a php array with images wanted to rotate, then we&#8217;ll apply the rand() php function.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$banners <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"path/img1<span class="phpOperator">.</span>jpg"</span>, <span class="phpString">"path/img2<span class="phpOperator">.</span>gif"</span><span class="phpOperator">)</span><span class="phpText">;</span>
$max <span class="phpOperator">=</span> <span class="phpFunction">sizeof</span><span class="phpOperator">(</span>$banners<span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpFunction">rand</span> <span class="phpOperator">=</span> <span class="phpFunction">rand</span><span class="phpOperator">(</span><span class="phpNumber">0</span>, $max<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">print</span> $banners<span class="phpOperator">[</span>$<span class="phpFunction">rand</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-random-banner-rotator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : Random link rotator</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-random-link-rotator/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-random-link-rotator/#comments</comments>
		<pubDate>Tue, 16 Dec 2008 12:28:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

		<category><![CDATA[link rotator]]></category>

		<category><![CDATA[php link rotator]]></category>

		<category><![CDATA[php random]]></category>

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

		<category><![CDATA[random link]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=27</guid>
		<description><![CDATA[Hi,
In this php tutorial you will learn how to build a random link rotator. Basically, we&#8217;ll build a php array with the links needed to rotate and then we&#8217;ll print to user the link randomly.

&#60;?php
$links = array("link 1", "link 2", "link 3");
$max = sizeof($links);
$rand = rand(0, $max);
print $links[$rand];
?&#62;

]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>In this php tutorial you will learn how to build a random link rotator. Basically, we&#8217;ll build a php array with the links needed to rotate and then we&#8217;ll print to user the link randomly.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$links <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"link <span class="phpNumber">1</span>"</span>, <span class="phpString">"link <span class="phpNumber">2</span>"</span>, <span class="phpString">"link <span class="phpNumber">3</span>"</span><span class="phpOperator">)</span><span class="phpText">;</span>
$max <span class="phpOperator">=</span> <span class="phpFunction">sizeof</span><span class="phpOperator">(</span>$links<span class="phpOperator">)</span><span class="phpText">;</span>
$<span class="phpFunction">rand</span> <span class="phpOperator">=</span> <span class="phpFunction">rand</span><span class="phpOperator">(</span><span class="phpNumber">0</span>, $max<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">print</span> $links<span class="phpOperator">[</span>$<span class="phpFunction">rand</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-random-link-rotator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : Send email with a contact form</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-send-email-with-a-contact-form/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-send-email-with-a-contact-form/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 21:30:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

		<category><![CDATA[contact form]]></category>

		<category><![CDATA[contact form by email]]></category>

		<category><![CDATA[html contact form]]></category>

		<category><![CDATA[php contact form]]></category>

		<category><![CDATA[php email]]></category>

		<category><![CDATA[send email]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=23</guid>
		<description><![CDATA[In this php tutorial you will learn how to setup a simple contact form which will be sent then by email. That needs to be done in two sides : html form and php contact form processing.
Html side is right here :

&#60;form action=&#34;&#34; method=&#34;POST&#34;&#62;
Full name : &#60;input type=&#34;text&#34; name=&#34;fullname&#34;&#62;&#60;br/&#62;
Email : &#60;input type=&#34;text&#34; name=&#34;email&#34;&#62;&#60;br/&#62;
Message : &#60;textarea [...]]]></description>
			<content:encoded><![CDATA[<p>In this php tutorial you will learn how to setup a simple contact form which will be sent then by email. That needs to be done in two sides : html form and php contact form processing.</p>
<p>Html side is right here :</p>
<pre class="html">
<span class="htmlFormTag">&lt;form action=<span class="htmlAttributeValue">&quot;&quot;</span> method=<span class="htmlAttributeValue">&quot;POST&quot;</span>&gt;</span>
Full name : <span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;text&quot;</span> name=<span class="htmlAttributeValue">&quot;fullname&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;br/&gt;</span>
Email : <span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;text&quot;</span> name=<span class="htmlAttributeValue">&quot;email&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;br/&gt;</span>
Message : <span class="htmlFormTag">&lt;textarea name=<span class="htmlAttributeValue">&quot;message&quot;</span>&gt;</span><span class="htmlFormTag">&lt;/textarea&gt;</span><span class="htmlOtherTag">&lt;br/&gt;</span>
<span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;submit&quot;</span> name=<span class="htmlAttributeValue">&quot;sb&quot;</span> id=<span class="htmlAttributeValue">&quot;sb&quot;</span> value=<span class="htmlAttributeValue">&quot;Send&quot;</span>&gt;</span>
<span class="htmlFormTag">&lt;/form&gt;</span>
</pre>
<p>And here it is the processing side</p>
<pre class="php">
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpFunction">isset</span><span class="phpOperator">(</span><span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'submit'</span><span class="phpOperator">]</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'fullname'</span><span class="phpOperator">]</span> <span class="phpOperator"><span class="phpOperator">=</span>=</span> <span class="phpString">"" || $_POST['email'] == ""</span> <span class="phpOperator">|</span><span class="phpOperator">|</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'message'</span><span class="phpOperator">]</span> <span class="phpOperator"><span class="phpOperator">=</span>=</span> <span class="phpString">""</span><span class="phpOperator">)</span>
print <span class="phpString">"Fields are mandatory"</span><span class="phpText">;</span>
<span class="phpKeyword"><span class="phpOperator">}</span>else<span class="phpOperator">{</span></span>
$to <span class="phpOperator">=</span> <span class="phpString">"youre<span class="phpFunction">mail</span>"</span><span class="phpText">;</span>
$from <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'e<span class="phpFunction">mail</span>'</span><span class="phpOperator">]</span><span class="phpText">;</span>
$subject <span class="phpOperator">=</span> <span class="phpString">"contact form"</span><span class="phpText">;</span>
$message <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'message'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpFunction">mail</span><span class="phpOperator">(</span>$to, $subject, $message<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-send-email-with-a-contact-form/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : How to make a file uploader</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-how-to-make-a-file-uploader/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-how-to-make-a-file-uploader/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 19:48:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Usefull PHP]]></category>

		<category><![CDATA[bulk file uploader]]></category>

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

		<category><![CDATA[php file uploader]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=19</guid>
		<description><![CDATA[Hi,
In this php tutorial you will learn how to make a file uploader. Less words, and here we are : first we create the html form

&#60;form action=&#34;&#34; method=&#34;POST&#34; enctype=&#34;multipart/form-data&#34;&#62;
Browse file to upload &#60;input type=&#34;file&#34; name=&#34;filetoupload&#34; id=&#34;filetoupload&#34;&#62;&#60;br/&#62;
&#60;input type=&#34;submit&#34; name=&#34;sb&#34; id=&#34;sb&#34; value=&#34;Upload now&#34;&#62;
&#60;/form&#62;

Now that we have the html form created, I&#8217;ve pushed the action on itself. So, [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>In this php tutorial you will learn how to make a file uploader. Less words, and here we are : first we create the html form</p>
<pre class="html">
<span class="htmlFormTag">&lt;form action=<span class="htmlAttributeValue">&quot;&quot;</span> method=<span class="htmlAttributeValue">&quot;POST&quot;</span> enctype=<span class="htmlAttributeValue">&quot;multipart/form-data&quot;</span>&gt;</span>
Browse file to upload <span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;file&quot;</span> name=<span class="htmlAttributeValue">&quot;filetoupload&quot;</span> id=<span class="htmlAttributeValue">&quot;filetoupload&quot;</span>&gt;</span><span class="htmlOtherTag">&lt;br/&gt;</span>
<span class="htmlFormTag">&lt;input type=<span class="htmlAttributeValue">&quot;submit&quot;</span> name=<span class="htmlAttributeValue">&quot;sb&quot;</span> id=<span class="htmlAttributeValue">&quot;sb&quot;</span> value=<span class="htmlAttributeValue">&quot;Upload now&quot;</span>&gt;</span>
<span class="htmlFormTag">&lt;/form&gt;</span>
</pre>
<p>Now that we have the html form created, I&#8217;ve pushed the action on itself. So, no need to create another separate page to process the data.</p>
<p>Here is the php code</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpFunction">isset</span><span class="phpOperator">(</span><span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'sb'</span><span class="phpOperator">]</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
$path <span class="phpOperator">=</span> <span class="phpString">"yourpath"</span><span class="phpText">;</span>
$file <span class="phpOperator">=</span> <span class="phpScriptVar">$_FILES</span><span class="phpOperator">[</span><span class="phpString">'filetoupload'</span><span class="phpOperator">]</span><span class="phpOperator">[</span><span class="phpString">'name'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpFunction">move_uploaded_file</span><span class="phpOperator">(</span><span class="phpScriptVar">$_FILES</span><span class="phpOperator">[</span><span class="phpString">'filetoupload'</span><span class="phpOperator">]</span><span class="phpOperator">[</span><span class="phpString">'tmp_name'</span><span class="phpOperator">]</span>, <span class="phpString">"$path/$file"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Bulk php file uploader is now done,</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-how-to-make-a-file-uploader/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : Function To Refresh a Page</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-function-to-refresh-a-page/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-function-to-refresh-a-page/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 12:43:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Short PHP Functions]]></category>

		<category><![CDATA[php function to refresh page]]></category>

		<category><![CDATA[php refresh]]></category>

		<category><![CDATA[refresh in a number of given seconds]]></category>

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=14</guid>
		<description><![CDATA[Well,
This php function uses the html meta tag and its refresh attribute. I use it because I can easily estabilish how many seconds to wait before refreshing the page : nice, isn&#8217;t it?
There is already a php function which refreshes a page, but there isn&#8217;t a way to pass the number of seconds needed before [...]]]></description>
			<content:encoded><![CDATA[<p>Well,</p>
<p>This php function uses the html meta tag and its refresh attribute. I use it because I can easily estabilish how many seconds to wait before refreshing the page : nice, isn&#8217;t it?</p>
<p>There is already a php function which refreshes a page, but there isn&#8217;t a way to pass the number of seconds needed before refreshes, it&#8217;s just refreshes the page when the php engine goes to the line of code.</p>
<p>Here is the function :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//<span class="phpFunctionKeyword">function</span> to refresh a page in a number of seconds
</span>
<span class="phpFunctionKeyword">function</span><span class="htmlText"> refreshPage</span><span class="phpOperator">(</span>$destination, $seconds<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="htmlText">
print </span><span class="phpString">"<span class="phpOperator">&lt;</span>meta http-equiv<span class="phpOperator">=</span>\"</span>refresh\<span class="phpString">" content<span class="phpOperator">=</span>\"</span>$seconds<span class="phpText">;</span> url=$destination\<span class="phpString">"<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-function-to-refresh-a-page/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PHP Tutorial : Function - Filter unwanted words</title>
		<link>http://crivionweb.com/phpblog/php-tutorial-function-filter-unwanted-words/</link>
		<comments>http://crivionweb.com/phpblog/php-tutorial-function-filter-unwanted-words/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 12:06:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Short PHP Functions]]></category>

		<category><![CDATA[custom php function]]></category>

		<category><![CDATA[filter unwanted words]]></category>

		<category><![CDATA[php filter]]></category>

		<category><![CDATA[php function]]></category>

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

		<guid isPermaLink="false">http://crivionweb.com/phpblog/?p=3</guid>
		<description><![CDATA[Hello,
I finded it usefull to build a simple and maximum 10 lines of code php function which can be used in filtering words that you wouldn&#8217;t want to appear on your website, forum, guestbook, comments, etc.
The most common way where is to use it within a html form, validating an input, textarea element, etc.
The code [...]]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>I finded it usefull to build a simple and maximum 10 lines of code php function which can be used in filtering words that you wouldn&#8217;t want to appear on your website, forum, guestbook, comments, etc.</p>
<p>The most common way where is to use it within a html form, validating an input, textarea element, etc.</p>
<p>The code is built and commented below :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//call the special word which builds a<span class="phpKeyword"> new </span><span class="phpFunctionKeyword">function</span>
</span>
<span class="phpComment">//custom php <span class="phpFunctionKeyword">function</span> and give it a nice name
</span><span class="phpFunctionKeyword">function</span><span class="htmlText"> filterMe</span><span class="phpOperator">(</span>$whatToFilter, $listOfUnwantedWords<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpKeyword">
foreach </span><span class="phpOperator">(</span>$listOfUnwantedWords<span class="phpKeyword"> as </span>$value<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">preg_match</span><span class="phpOperator">(</span><span class="phpString">"/$value/i"</span>, <span class="phpString">"$whatToFilter"</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="htmlText">
print </span><span class="phpString">"You have used an unallowed word"</span><span class="phpText">;</span>
<span class="phpFunction">exit</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Usage of this php function to filter unwanted words : firstly, build an php array with unwanted words, then apply the function where you need it. Example :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//create <span class="phpFunction">array</span> with not wanted words
</span>
$Unwanted <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"www"</span>, <span class="phpString">"mywebsite"</span>, <span class="phpString">"etc"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//estabilish which given word to filter
</span>
$word <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'yourinput'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpComment">//<span class="phpFunctionKeyword">function</span> in action
</span>
<span class="htmlText">
filterMe</span><span class="phpOperator">(</span>$word, $Unwanted<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Feel free to use it anywhere!</p>
]]></content:encoded>
			<wfw:commentRss>http://crivionweb.com/phpblog/php-tutorial-function-filter-unwanted-words/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
