<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">
<channel>
	<title>Slipszenko.net - Tutorial Feed</title>
    <link>http://www.slipszenko.net/</link>
    <description>Slipszenko.net Feed</description>
    <language>en-us</language>
	<item>
		<title>PHP With Forms</title>
		<link>http://www.slipszenko.net/tutorial:PHP+With+Forms</link>
		<description><![CDATA[<p>This tutorial should give you a good knowledge of using PHP to process forms for sending email, uploading files or processing user information, it is aimed at beginners looking to get better or an intermediate looking to remind him/herself.</p>
<p>Just going to do a simple introduction for the ABSOLOUTE beginners if you want to skip it, click <a href="#skipsimple">here</a>. One of the most useful things with php is how easy it is to handle variables and process them. Here is a really simple example of a variable being passed on:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if(!isset(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">]))<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&nbsp;action="<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$_SERVER</span><span style="color: #007700">[</span><span style="color: #DD0000">'PHP_SELF'</span><span style="color: #007700">];&nbsp;</span><span style="color: #0000BB">?&gt;</span>"&nbsp;method="post"&nbsp;id="nameform"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Name:&nbsp;&lt;input&nbsp;type="text"&nbsp;name="name"&nbsp;id="name"&nbsp;/&gt;&lt;br&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;input&nbsp;type="submit"&nbsp;name="submit"&nbsp;id="submit"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/form&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />else<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'name'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Hello:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$name</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This simple bit of code first uses the if statment to check if the variable has been filled in (and if we therefore know there name). The code will allow us to display "Hello" followed by there name, for a bit of personalisation.</p>
<a name="skipsample"></a>
<p>Let's face it though, this is quite useless and theres not really going to a site when your going to want to do this. So lets try something a bit more useful: Sending Email's via forms.</p>
<p>Here's the code, I'll explain it after:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if(!isset(</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'submit'</span><span style="color: #007700">]))<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&lt;form&nbsp;action="contact.php"&nbsp;class="niceform"&nbsp;method="post"&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;class="label"&gt;&lt;label&nbsp;for="yourname"&gt;Your&nbsp;Name:&lt;/label&gt;&lt;/div&gt;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="yourname"&nbsp;id="yourname"&nbsp;/&gt;&lt;br&nbsp;class="clear"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;class="label"&gt;&lt;label&nbsp;for="youremail"&gt;Your&nbsp;Email:&lt;/label&gt;&lt;/div&gt;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="youremail"&nbsp;id="youremail"&nbsp;/&gt;&lt;br&nbsp;class="clear"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;class="label"&gt;&lt;label&nbsp;for="subject"&gt;Subject:&lt;/label&gt;&lt;/div&gt;&nbsp;&lt;input&nbsp;type="text"&nbsp;name="subject"&nbsp;id="subject"&nbsp;/&gt;&lt;br&nbsp;class="clear"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;class="label"&gt;&lt;label&nbsp;for="message"&gt;Message:&lt;/label&gt;&lt;/div&gt;&nbsp;&lt;textarea&nbsp;name="message"&nbsp;id="message"&gt;&lt;/textarea&gt;&lt;br&nbsp;class="clear"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div&nbsp;class="submit"&gt;&lt;input&nbsp;class="sub"&nbsp;type="submit"&nbsp;name="submit"&nbsp;id="submit"&nbsp;value="Submit"&nbsp;/&gt;&lt;/div&gt;&lt;br&nbsp;class="clear"&nbsp;/&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/form&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;*All&nbsp;fields&nbsp;are&nbsp;required.<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />else<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'yourname'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$subject&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'subject'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$message&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'message'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$email&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_POST</span><span style="color: #007700">[</span><span style="color: #DD0000">'youremail'</span><span style="color: #007700">];<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$from&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"From:&nbsp;Contact&nbsp;Form"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;if(!empty(</span><span style="color: #0000BB">$name</span><span style="color: #007700">)&nbsp;||&nbsp;!empty(</span><span style="color: #0000BB">$subject</span><span style="color: #007700">)&nbsp;||&nbsp;!empty(</span><span style="color: #0000BB">$message</span><span style="color: #007700">)&nbsp;||&nbsp;!empty(</span><span style="color: #0000BB">$email</span><span style="color: #007700">))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">mail</span><span style="color: #007700">(</span><span style="color: #DD0000">"youremail@yoursite.com"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$subject</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"From:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$email</span><span style="color: #007700">.</span><span style="color: #DD0000">"/n"</span><span style="color: #007700">.</span><span style="color: #0000BB">$message</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$from</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//Change&nbsp;email&nbsp;address&nbsp;on&nbsp;this&nbsp;line&nbsp;to&nbsp;your&nbsp;own&nbsp;email&nbsp;address!<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Thank&nbsp;you&nbsp;for&nbsp;the&nbsp;email,&nbsp;I'll&nbsp;try&nbsp;to&nbsp;reply&nbsp;as&nbsp;soon&nbsp;as&nbsp;I&nbsp;can.&nbsp;Return&nbsp;to&nbsp;the&nbsp;&lt;a&nbsp;href="/"&gt;home&nbsp;page&lt;/a&gt;?<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;else<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">?&gt;<br /></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You&nbsp;appear&nbsp;to&nbsp;have&nbsp;left&nbsp;a&nbsp;field&nbsp;blank,&nbsp;please&nbsp;go&nbsp;&lt;a&nbsp;href="contact.php"&gt;back&lt;/a&gt;&nbsp;and&nbsp;try&nbsp;again.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This is the code for a simple contact form. Copy this code to a file called contact.php, and upload it or save it to your testing server.</p>
<p>First we check to see if the form has been submited or not by checking the variable automatically set when you submit the contact form, if it hasn't been set then we display the contact form (if you want the styles, steal them from my <a href="/css/style.css">stylesheet</a>, :P). If they have sumbited the form then we process the information they've passed to the server.</p>
<p>First we put all of the $_POST varibales into shorthand variables. This makes it easier to refer to them later in the page. Then we use another if statement to check if any of the variables are empty, if they are then we tell the user that they've missed something out and give them a link to re-try using the contact form. If they filled everything in then it send the email to the seleceted email address and gives them a message informing them of this.</p>
<p>I'm going to leave it there for now, check back tomorrow and I'll have the rest online! Including how to upload files, just gotta get back to A-Level studys now.</p>]]></description>
		<pubDate>2007-12-09 05:17:37</pubDate>
	</item>
		<item>
		<title>Beginners PHP Part 3</title>
		<link>http://www.slipszenko.net/tutorial:Beginners+PHP+Part+3</link>
		<description><![CDATA[<p>Before your start this tutorial, unless you have a good understanding of php variables and if statements, please go back and read part <a href="/tutorial:Beginners+PHP+Part+1">1</a> and/or <a href="/tutorial:Beginners+PHP+Part+2">2</a> of this tutoial. If you have already done that or already understand these topics, please read on.</p>
<p>In the last tutorial we looked at the use of if statements, whilst they're very useful, it begin's to become annoying when we've got loads of elseif's. A better alternative is to use a "switch" statement. Here is an example of one:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">switch(</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">])<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #DD0000">"news"</span><span style="color: #007700">:&nbsp;</span><span style="color: #FF8000">//So&nbsp;the&nbsp;URL&nbsp;will&nbsp;be:&nbsp;index.php?page=news<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"It's&nbsp;the&nbsp;news&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #DD0000">"contact"</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"It's&nbsp;the&nbsp;contact&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;</span><span style="color: #DD0000">"info"</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"It's&nbsp;the&nbsp;info&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;default:&nbsp;</span><span style="color: #FF8000">//So&nbsp;the&nbsp;URL&nbsp;will&nbsp;be:&nbsp;index.php&nbsp;OR&nbsp;index.php?page=(anything&nbsp;that&nbsp;isn't&nbsp;news,&nbsp;contact&nbsp;or&nbsp;info)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Home&nbsp;Page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>First we execute the switch statement and then open the curly braces {}'s to contain all the diferent options. Each option is then started with a "case" statement, and then the value of your option, in this case the GET variale of "page", is encased within quotation marks. Php will then run all the code between that and the finishing point which is marked with a "break;". As you can see in the code example above we can also have "default:" instead or "case:", this can be used to process code as a default, (as you might have quessed from the name), if the value doesn't equal any of the options. Hope this has been useful to you thus far!</p>
<p>Now let's look at one of the most useful, things possibly with php, SSI (Server side includes). There are two functions: require() and include(). First I shall example how they are used and then I shall and then I shall discuss the diferences between them.</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">require(</span><span style="color: #DD0000">"includes/example.php"</span><span style="color: #007700">);<br />include(</span><span style="color: #DD0000">"includes/example.php"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>As you can see, they both work in very similar ways. All you do is call the function and tell it where the file is! Simple :P</p>
<p>The only difference between the two really is that if require() fails to find the file, the entire page won't load. Whereas if include() fails to find the file you told me to, it will simply display an error message.</p>
<p>As always, I hope that you have found this tutorial useful. This is the last of the beginners php tutorials. I'm going to be making some more tutorial's for php, on slightly more specific subject's such, as email and mysql interaction with php. Bye!</p>]]></description>
		<pubDate>2007-10-18 20:47:09</pubDate>
	</item>
		<item>
		<title>Beginners PHP Part 2</title>
		<link>http://www.slipszenko.net/tutorial:Beginners+PHP+Part+2</link>
		<description><![CDATA[<p>Before your start this tutorial, unless you have a basic understanding of php variables, please go back and read part 1 of this tutoial found <a href="/tutorial:Beginners+PHP+Part+1">here</a>. If you have already done that or already understand variables please read on.</p>
<p>The last tutorial didn't really tell us much that would make the site dynamic as such. But now I think we're ready to go onto something a lot more interesting and a lot more useful, "if" statements:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if(</span><span style="color: #0000BB">1&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"One&nbsp;Does&nbsp;Equal&nbsp;One!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This code is the basic design for an "if" statement, first we simply start the "if" function which then checks what's whichin the brackets "()" to see if it's true or false. In this case, we're checking to see if 1 is equivalent to 1. If so we run the code within the curly brace's "{}". So basicly this statement says that if 1 equals 1 then we display "One Does Equal One!". The "==" is a comparison operater. There are several other comparison operators, here are a few of the most useful ones:</p>
<table class="nice">
	<tr>
		<td><strong>Comprison Operator</strong></td>
		<td><strong>Meaning</strong></td>
		<td><strong>Usage</strong></td>
	</tr>
	<tr>
		<td>==</td>
		<td>Is Equal To</td>
		<td>To check if the criteria are equal to each other.</td>
	</tr>
	<tr>
		<td>!=</td>
		<td>Is Not Equal To</td>
		<td>To check if the criteria are not equal to each other.</td>
	</tr>
	<tr>
		<td>&lt; OR &gt;</td>
		<td>Is bigger than OR is smaller than.</td>
		<td>To check if the criteria is bigger than the other OR to check if the criteria is smaller than the other</td>
	</tr>
	<tr>
		<td>=&lt; OR =&gt;</td>
		<td>Is bigger than or equal to OR is smaller than or equal to.</td>
		<td>To check if the criteria is bigger than or equal to the other OR to check if the criteria is smaller than or equal to the other</td>
	</tr>
</table>
<p>You don't have to use set amounts as the "if" statements criteria, you can use variables (It all starts to link in, see). So we can do this:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">];<br />if(</span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"news"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;the&nbsp;news&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>Also, php "if" statements can be extended by adding "else" and "elseif" statements like this:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">];<br />if(</span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"news"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;the&nbsp;news&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />elseif(</span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"home"</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;the&nbsp;home&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />else<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"This&nbsp;is&nbsp;not&nbsp;the&nbsp;news&nbsp;or&nbsp;the&nbsp;home&nbsp;page!"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This code first checks to see if the variable page, taken from the query string on the URL has the value "news", if it is it displays "This is the news page!", if not it checks to see if the $page variable has the value of home and if so displays "This is the home page!", if it isn't then it displays: "This is not the news or the home page!".</p>
<p>If you have any problems with this leave a comment and I shall try to ammend this tutorial to help you out. That's all for now, but I shall be uploading part 3 soon. To be the first to find out when, subscribe to the rss feed.</p>
<p>EDIT: Part 3 Now Available: <a href="/tutorial:Beginners+PHP+Part+3">Here</a></p>]]></description>
		<pubDate>2007-10-16 14:27:36</pubDate>
	</item>
		<item>
		<title>Beginners PHP Part 1</title>
		<link>http://www.slipszenko.net/tutorial:Beginners+PHP+Part+1</link>
		<description><![CDATA[<p>Before I start I really want to emphasize that this is a tutorial for the absolute beginner! If you have experience with php I recommend you stop reading, if not this is the tutorial for you! If you have some web space available to use the code as I give it to you please do so, otherwise try downloading <a href="http://www.wampserver.com/en/index.php">WAMP server</a> to test it on instead.</p>
<p>First It's best to check your servers php information: </p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />phpinfo</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>Save that to a file called "phpinfo.php" and upload it or install or put it on your localhost folder, which ever is relevant to you. This will bring up a large page containing all the information on your php installation, from it's version to all the Libras (extra optional function sets) installed on it. This also allows us to find out if php is definitely installed on the server. Assuming php is installed correctly on the server please read on.</p>
<p>Blocks of php are usually stared with a "<code>&lt;?php</code>" and finished with a "<code>?&gt;</code>". There are other ways of doing it, but this is the usual way to do it. So some php code would look like this:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Hello&nbsp;World!"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This code will simply display the words "Hello World", with the echo function telling php to display whatever is within the quotation marks.</p>
<p>The next step up from displaying text, will be using commenting in php. Php comments, are similar to HTML comments in many ways, except it is impossible for visitors to see them, even if they choose to view the source There are several ways to comment in php, single lint comments like this: </p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//Single&nbsp;Line&nbsp;Comment!<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>Or block comments like this:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*<br />Amazingly,&nbsp;Shockingly&nbsp;and<br />Incredibly&nbsp;cool&nbsp;comment<br />block.&nbsp;WOW!<br />*/<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>These are useful for reminding yourself what different sections of the script do.</p>
<p>The next step up is the use of variable! We're starting to get somewhere now! Here's an example:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$message&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"Hello&nbsp;World!&nbsp;I'm&nbsp;a&nbsp;variable!"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$message</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This bit of script create's the variable called message and stores the text within the quotation marks in it. As you can see the variable has to start with a "$" sign. In php you don't have to declare variables, like you do in asp. There are a few rules with variables, firstly the must be named with just alpha-numeric characters or underscores (a-zA-Z0-9 and _). And they must start with a letter or an underscore. Variables can be used to store numbers too like so: </p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$one&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$two&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$answer&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$one&nbsp;</span><span style="color: #007700">+&nbsp;</span><span style="color: #0000BB">$two</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$answer</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>This code will take the variable $one (with the value of 1) and the variable $two (with the value of 2). And then adds the two variables together and stores them in the variable $answer and then displays them using the echo function.</p>
<p>We shall now look at getting variables from the URL query string. You know how some websites have URL's like:</p>
<p>http://www.example.com/index.php?page=news</p>
<p>This is creating a variable called page and giving it the value news. To refer to this variable in a php script we use do this:</p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">];<br />echo&nbsp;</span><span style="color: #0000BB">$page</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>The Super Global $_GET refers to GET variables (variables passed to the server via the URL) and then gets the one called page and gives it whatever the value is that is set in the URL and then stores it in the variable named $page. Finally it uses the echo function to display it.</p>
<p>This is all for now folks, but I shall be uploading part 2 soon! To see when that's added subscribe to the rss feed! Hope this has been useful!</p>
<p>EDIT: Part 2 Now Available: <a href="/tutorial:Beginners+PHP+Part+2">Here</a></p>]]></description>
		<pubDate>2007-10-15 19:02:32</pubDate>
	</item>
		<item>
		<title>Making Clean URLs</title>
		<link>http://www.slipszenko.net/tutorial:Making+Clean+URLs</link>
		<description><![CDATA[<p>First I think it's best if I make it clear what a messy URL looks like: </p>
<p>http://www.example.com/index.php?page=news&id=01</p>
<p>And here is what a clean URL could look like: </p>
<p>
http://www.example.com/news/first+blog+post/<br />
http://www.example.com/tutorial:easy+php+tutorial
</p>
<p>See how much better that looks? Here are a few reasons to use clean URLs: </p>
<ol>
<li>You can change where the page is but not lose any bookmarks (Thanks, to Mod_rewrite),</li>
<li>They are easy to remember,</li>
<li>Search engine's prefer it (Did you know that yahoo, msn and loads of other search engines (except google, thankfully) just ignore a page with a "?" in the URL),</li>
<li>And of course they look a lot nicer.</li>
</ol>
<p>All this is thanks to the .htaccess file and Mod_rewrite. So lets get on with it! First you open your code favourite editor and save a blank file called ".htaccess" and then add the line: </p><div class="codetitle">Code Box</div><div class="code"><code><span style="color: #000000">
RewriteEngine&nbsp;On</span>
</code></div>
<p>This tells apache to turn Mod_rewrite on. Now we need to create our RewriteRule(s). My first examples rule will look like this</p>
<div class="codetitle">Code Box</div><div class="code"><code><span style="color: #000000">
RewriteRule&nbsp;^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$&nbsp;index.php?page=$1&amp;id=$2</span>
</code></div>
<p>I shall now explain this in a bit more detail:</p>
<ul>
<li>First we state that we're creating a rewrite by starting the line with: "RewriteRule",</li>
<li>Then we use a "^" to state that we're creating our rule,</li>
<li>Then we use Regular expressions to state what characters are allowed in the variable which we express in the next part,</li>
<li>Then we use a $ sign to state the end of the clean URL ready to convert it to the messy URL to be read by the server,</li>
<li>We tell the server what the URL should read and use $1, $2, $3 etc. To display the variables.</li>
</ul>
<p>You might also choose to add this line too:</p>
<div class="codetitle">Code Box</div><div class="code"><code><span style="color: #000000">
RewriteRule&nbsp;^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/$&nbsp;index.php?page=$1&amp;id=$2</span>
</code></div>
<p>So that we may have a trailing slash on the URL.</p>
<p>There may be a few issues to rise with using a RewriteRule that looks like a set of directories.  This is becase file's (such as the stylesheet and the images) will be linked to relative to the directory that the rule makes it look like it's in, as opposed to relative to where the file really is. This can be easily fixed by linking to such files from the site root instead. But I prefer to seperate the variables in the clean URL with a ":" as doesn't effect how you link to files and personally I think it looks better.</p>
<p>Something you may want to consider is when you have spaces in the variables in the clean URL. By modifying the regular expression in the URL to:</p>
<div class="codetitle">Code Box</div><div class="code"><code><span style="color: #000000">
([a-zA-Z0-9+]+)</span>
</code></div>
<p>You enable there to be "+"'s in the clean URL, then when you get the url try this php code to turn them back into spaces: </p>
<div class="codetitle">Php Code Box</div><div class="code"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$_GET</span><span style="color: #007700">[</span><span style="color: #DD0000">'page'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">$page&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">str_replace</span><span style="color: #007700">(</span><span style="color: #DD0000">"+"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$page</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$page</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
<p>I hope this tutorial has been useful to you!</p>]]></description>
		<pubDate>2007-10-09 18:31:42</pubDate>
	</item>
	</channel>
</rss>	