<?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>Ross Tanner</title>
	<atom:link href="http://rosstanner.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://rosstanner.co.uk</link>
	<description>Freelance Web Developer Gloucestershire</description>
	<lastBuildDate>Tue, 14 May 2013 14:28:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>SEO &#8211; Google Penguin 2.0 is coming!</title>
		<link>http://rosstanner.co.uk/2013/05/seo-google-penguin-2-0-is-coming/</link>
		<comments>http://rosstanner.co.uk/2013/05/seo-google-penguin-2-0-is-coming/#comments</comments>
		<pubDate>Mon, 13 May 2013 19:52:22 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[Matt Cutts]]></category>
		<category><![CDATA[Penguin]]></category>
		<category><![CDATA[Penguin 2.0]]></category>
		<category><![CDATA[search engine optimisation]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=534</guid>
		<description><![CDATA[<p>According to <a href="http://www.mattcutts.com/blog/what-to-expect-in-seo-in-the-coming-months/" target="_blank">Matt Cutt&#8217;s latest Google Webmaster&#8217;s video</a>, Penguin 2.0 is coming very soon. Although an official date has yet to be announced, Matt did say that Google were &#8220;relatively close&#8221; to deploying the next generation of Penguin and it&#8217;s expected within the next couple of weeks.</p> <p>@<a href="https://twitter.com/mrjamiedodd">mrjamiedodd</a> we do expect to [...]]]></description>
				<content:encoded><![CDATA[<p>According to <a href="http://www.mattcutts.com/blog/what-to-expect-in-seo-in-the-coming-months/" target="_blank">Matt Cutt&#8217;s latest Google Webmaster&#8217;s video</a>, Penguin 2.0 is coming very soon. Although an official date has yet to be announced, Matt did say that Google were &#8220;relatively close&#8221; to deploying the next generation of Penguin and it&#8217;s expected within the next couple of weeks.</p>
<blockquote class="twitter-tweet" data-conversation="none"><p>@<a href="https://twitter.com/mrjamiedodd">mrjamiedodd</a> we do expect to roll out Penguin 2.0 (next generation of Penguin) sometime in the next few weeks though.</p>
<p>&mdash; Matt Cutts (@mattcutts) <a href="https://twitter.com/mattcutts/status/332917182990258176">May 10, 2013</a></p></blockquote>
<p><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p><strong>What is Penguin?</strong></p>
<p>Penguin is a code name given to Google algorithm update first released in April 2012 and since updated in May and October of the same year. The update&#8217;s main goal was to improve the way that Google looked at black-hat SEO techniques and ultimately penalising those that violated the Google Webmaster Guidelines. It would look at many factors such as keyword stuffing, paying for links, duplicate content and cloaking.</p>
<p>As I&#8217;ve heavily worked in the affiliate sector, a lot of websites I&#8217;ve put together were data feed based and therefore contained content which was readily available by thousands of other affiliates. This caused issues with duplicate content and Google quickly penalised a lot of websites in the sector. Since that time we&#8217;ve spent a lot of time putting together bespoke content for ourselves and our clients which has helped combat that particular issue and hopefully any future Penguin updated. We weren&#8217;t the only ones affected but it goes to show that the algorithm updates work well.</p>
<p><strong>What is new in Penguin 2.0?</strong></p>
<p>Google is very unlikely to reveal the specifics behind the update but we are, of course, expecting it to improve the current algorithm of combating bad back-linking strategies and black-hat SEO. No doubt it will aim to tighten up the current rules and penalise those who originally were unaffected despite violating Google&#8217;s terms. If you were lucky enough to escape the first launch and the recent updates, this one might just catch you out. Apparently we&#8217;re expecting 2.0 to be a big update.</p>
<p><strong>Will I be affected by Penguin?</strong></p>
<p>Chances are you had experienced the last Penguin update. If you have high-quality written content with genuine linking methods then you&#8217;ll be fine. Google estimated that the initial Penguin launch affected approximately 3.1% of English search queries, update 1.1 just 0.1% and update 1.2 approximately 0.3%. It&#8217;s hard to say at this stage what percentage of queries will be affected, but we&#8217;re expecting a higher percentage.</p>
<p>Interflora are a very good example of a brand that was affected by Penguin. Their campaign of offering free flowers to bloggers in return for a link hit them, and hit them hard. Their unethical back-linking strategy caused them to be penalised by Google and they lost their search rankings, even for their own brand terms. I wouldn&#8217;t like to estimate what this eventually cost them but they definitely wouldn&#8217;t have welcomed the penalty.</p>
<p>The sites that were penalised the most were those that had too much exact match anchor text and bad link strategies which were deemed unnatural. It&#8217;s best to stick with an ethical way of generating back links and that is through what Google love best &#8211; high quality content that is shared at the user&#8217;s discretion.</p>
<p>Watch the video of Matt talking about the latest updates at Google and specifically Penguin 2.0:</p>
<p><iframe width="560" height="315" src="http://www.youtube.com/embed/xQmQeKU25zg" frameborder="0" allowfullscreen></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2013/05/seo-google-penguin-2-0-is-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing: Forrk</title>
		<link>http://rosstanner.co.uk/2013/05/introducing-forrk/</link>
		<comments>http://rosstanner.co.uk/2013/05/introducing-forrk/#comments</comments>
		<pubDate>Fri, 10 May 2013 21:24:56 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Social Media]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[forrk]]></category>
		<category><![CDATA[instagram]]></category>
		<category><![CDATA[social]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web design]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=530</guid>
		<description><![CDATA[<p>This somewhat contradicts my freelancing but I&#8217;d like to introduce an exciting new venture: <a href="http://forrk.co.uk">Forrk</a>. Forrk is a digital agency specialising in creating revolutionary web designs, applications and social widgets. It is due to launch within the next couple of weeks once the website is complete.</p> <p>Although we haven&#8217;t yet officially launched, we have [...]]]></description>
				<content:encoded><![CDATA[<p>This somewhat contradicts my freelancing but I&#8217;d like to introduce an exciting new venture: <a href="http://forrk.co.uk">Forrk</a>. Forrk is a digital agency specialising in creating revolutionary web designs, applications and social widgets. It is due to launch within the next couple of weeks once the website is complete.</p>
<p>Although we haven&#8217;t yet officially launched, we have many exciting projects planned for the near future. We plan to kick things off with some very cool social applications (no spoilers here today :-)) and ultimately provide a high-quality service to current and potential clients. On top of that we have a very sophisticated affiliate tracking engine to launch to the public and a platform which many marketers will find useful. It&#8217;s a very exciting time.</p>
<p>The team is made up of three co-founders: myself, the influential <a href="http://twitter.com/10yetis">Andy Barr</a> and the talented <a href="http://twitter.com/ddarrko">Daniel Benzie</a>. Together we bring a whole range of experience and skill sets, ranging from development, design, business, marketing and PR.</p>
<p>This isn&#8217;t an end to my freelancing though. I aim to continue my success being self-employed but at the same time demoting a lot of time to the agency. This freelance web developer blog will continue and I aim to post much more often than I have been. I feel there is much experience and expertise that I can provide to the industry, as I have already done through here, as well as learning from my comments, visitors and messages. I&#8217;ll also keep you updated with all the goings on at Forrk and of course our social apps.</p>
<p>If you&#8217;d like to find out more about us then be sure to follow <a href="http://twitter.com/weareforrk">@weareforrk</a> on Twitter.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2013/05/introducing-forrk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improving your on-site SEO</title>
		<link>http://rosstanner.co.uk/2013/02/improving-on-site-seo/</link>
		<comments>http://rosstanner.co.uk/2013/02/improving-on-site-seo/#comments</comments>
		<pubDate>Wed, 27 Feb 2013 18:15:47 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[SEO]]></category>
		<category><![CDATA[bing]]></category>
		<category><![CDATA[crawlers]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[googlebot]]></category>
		<category><![CDATA[robots]]></category>
		<category><![CDATA[search engine optimisation]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[seo]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=516</guid>
		<description><![CDATA[<p>As a freelance web developer I&#8217;ve found that the SEO world is very much dog-eat-dog. I&#8217;m on my own out there in the SERP world and I have to try and rank against many thousands of other freelancers. I think I&#8217;m doing quite well, especially localised searches, but I want to expand out and pick [...]]]></description>
				<content:encoded><![CDATA[<p>As a <strong>freelance web developer</strong> I&#8217;ve found that the SEO world is very much dog-eat-dog. I&#8217;m on my own out there in the SERP world and I have to try and rank against many thousands of other freelancers. I think I&#8217;m doing quite well, especially localised searches, but I want to expand out and pick up national, if not international, clients. There is no better free way of doing this than shooting up the search engine rankings.</p>
<p>As I very much focused all of my attention on these localised searches (I was new to the scene and didn&#8217;t want any major clients at the time) and pretty much conquered this, I&#8217;m now looking to expand my horizons. So, I thought I would put my best practices back into action and share with you guys how to improve your on-site search engine optimisation. Of course this doesn&#8217;t mean you will instantly move up the rankings as you&#8217;ll need to look at other factors such as off-site SEO, content, social interaction, user experience, etc) but it should go a long way and put your site in the right position to start doing so.</p>
<p>Here are the top things that I have found out over the years through research and trial and error. Google and other major search engines change their algorithms all the time and it&#8217;s all about keeping on top of these changes and altering your site to keep with their guidelines. However these tips are certainly all good points and should be considered strongly when looking at improving on-site SEO.</p>
<p><strong>Ensure your website can be read by search engine crawlers<br />
</strong>Priority: <span style="color: #ff0000;"><strong>HIGH</strong></span></p>
<p><strong></strong><span style="text-decoration: underline;">This is key</span>. How can search engines index your website if they can&#8217;t even access it? Look into your Robots.txt file and ensure you aren&#8217;t restricting access to your core content. <a title="Google Webmaster Tools" href="https://www.google.com/webmasters/tools/" target="_blank">Google Webmaster Tools</a> has a handy section for this, so ensure you are using what search engines are freely providing for you. <a title="Googlebot" href="http://support.google.com/webmasters/bin/answer.py?hl=en&amp;answer=182072" target="_blank">This article about Googlebot</a> provides detailed information about their robot and how it accesses and ultimately indexes your content &#8211; it&#8217;s a good read.</p>
<p><strong>Use the canonical meta tag<br />
</strong>Priority: <strong><span style="color: #ff0000;">HIGH</span><br />
</strong></p>
<p><strong></strong>Relatively new to the optimisation scene but it is incredibly handy and can prevent duplicate content issues much easier than before. Matt Cutts has created several videos around the duplicate content topic and the canonical tag:</p>
<p><iframe src="http://www.youtube.com/embed/Cm9onOGTgeM" height="315" width="560" allowfullscreen="" frameborder="0"></iframe></p>
<p>Make sure you only ever use one instance of it on a page though or it could potentially effect your SEO (not in a good way!). Also, triple-check that the URL you specify is correct otherwise you could end up losing your rankings to somebody else.</p>
<p><strong>Avoid keyword stuffing<br />
</strong>Priority: <span style="color: #ff0000;"><strong>HIGH</strong></span></p>
<p>Anyone who has been on the SEO scene for a long time will know that keyword stuffing is a thing of the past. Originally search engines would read the meta keywords tag but this has since been deprecated. Then developers turned to stuffing their content with their chosen keyword but search engines have since become much more aware of this and added it to their algorithms. You need to keep a good keyword-to-content percentage ratio as low as possible. There is no official figure but generally I always aim for use every other paragraph or so, just so that it&#8217;s noticeable but not too noticeable.</p>
<p><strong>Keyword usage in meta title<br />
</strong>Priority: <span style="color: #339966;"><strong>MEDIUM</strong></span></p>
<p>As ever, the meta title is one of the most important areas for SEO. Sometimes it can be concentrated on a little <em>too </em>much. It has been shown that exact keyword usage in the meta title has a direct affect on search engine rankings so ensure that your keywords are present, but don&#8217;t stuff it. I generally aim for 70 characters or less in the meta title because you need to remember that SERP have a limit. Always put the main keyword at the front of the meta title too so that it will always appear on these search engine results pages.</p>
<p><strong>Keyword usage in H1 tag<br />
</strong>Priority:<strong> <span style="color: #339966;"><strong>MEDIUM</strong></span><br />
</strong></p>
<p><strong></strong>If you know HTML then you know how important the heading tags can be (and I don&#8217;t just mean for SEO). Search engine crawlers will look for structured code and the best way of showing this is by using heading tags in the correct structure and format. Always aim to have a maximum of one H1 tag on a page and ensure that it contains your keyword. This has proven to have a <em>slight</em> affect on rankings so I always make sure this is written.</p>
<p><strong>Emphasise your keywords<br />
</strong>Priority: <span style="color: #339966;"><strong>MEDIUM</strong></span></p>
<p>This isn&#8217;t so important but has proven to affect rankings. By emphasising keywords, for example <strong>improve on-site SEO</strong>, it tells the crawlers that this is an important phrase on this page. It makes the crawler stand up and take notice and will also go hand-in-hand with the good use of keywords in the content to ensure that phrase is the main one for the page.</p>
<p><strong>Avoid excessive links<br />
</strong>Priority: <strong><span style="color: #ffcc00;">LOW</span></strong></p>
<p>Search engines will only follow a certain amount of links on a page before it gets bored. From knowledge Google will only crawl the first 100 links on a page so ensure that your more prominent content it towards the top (make use of this in a navigation bar) and keep content in sidebars refreshing/scrolling so that crawlers will find all content on your website. Although this can be combated through the use of sitemaps (see below), it&#8217;s always advised to prevent link stuffing.</p>
<p><strong>Use sitemaps<br />
</strong>Priority:<span style="color: #339966;"><strong> MEDIUM</strong></span></p>
<p>I haven&#8217;t given this a high priority because a well written and structured website will be crawled naturally. You should always create an XML sitemap though and submit this to the many search engines using their submission forms and webmaster tools. This will then tell the crawlers exactly where to go and should, in theory, index your content quicker than it would naturally.</p>
<p><strong>W3C validate your website<br />
</strong>Priority:<span style="color: #339966;"><strong> MEDIUM</strong></span></p>
<p>Validation of HTML and CSS code will improive accessibility to your website. A website that can be accessed and rendered correctly in all web/mobile browsers on all operating systems has a higher chance of being read easily by search engines. <a href="http://validator.w3.org/" target="_blank">W3C</a> have fantastic validators and should always be your first port of call.</p>
<p><strong>Protect your files and directories<br />
</strong>Priority: <span style="color: #ff0000;"><strong>HIGH</strong></span></p>
<p><span style="color: #000000;">Make sure that you have the correct permissions set on files and directories on your web server. As your site improves in terms of SEO visibility, so will the amount of spam targeting your website. Ensure that folders aren&#8217;t writable (where possible) and that files cannot be injected by third-parties. The last thing you want is malware being injected into your files and then search engines blacklisting you. More importantly, your users don&#8217;t want viruses from you otherwise they&#8217;ll never return.</span></p>
<p>I&#8217;ll keep updating this article as I research and find out more information which I think can be of use. Additionally, if you have any comments, suggestions or questions then please do use the comments area below and I can answer your queries or even add to my article with your suggestions.</p>
<p>If this article has been of use then please let me know so that I can use you as a case study and please also share this article so that others can also benefit. You can share using the icons below and around this website.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2013/02/improving-on-site-seo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>User Membership System Part 2: Logging In</title>
		<link>http://rosstanner.co.uk/2013/02/user-membership-system-part-2-logging/</link>
		<comments>http://rosstanner.co.uk/2013/02/user-membership-system-part-2-logging/#comments</comments>
		<pubDate>Mon, 18 Feb 2013 20:59:06 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[membership system]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[user system]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=498</guid>
		<description><![CDATA[<p><a title="view the demo" href="http://rosstanner.co.uk/p/user-registration/register.html" target="_blank" rel="nofollow">VIEW THE DEMO [PART 1]</a><br /> <a title="view the demo" href="http://rosstanner.co.uk/p/user-registration/login.html" target="_blank" rel="nofollow">VIEW THE DEMO [PART 2]</a></p> <p>Welcome to part 2 of my User Membership Tutorial series. In the last part I covered the basics of registering an account which would insert into a database. That part of the series [...]]]></description>
				<content:encoded><![CDATA[<p><a title="view the demo" href="http://rosstanner.co.uk/p/user-registration/register.html" target="_blank" rel="nofollow">VIEW THE DEMO [PART 1]</a><br />
<a title="view the demo" href="http://rosstanner.co.uk/p/user-registration/login.html" target="_blank" rel="nofollow">VIEW THE DEMO [PART 2]</a></p>
<p>Welcome to part 2 of my User Membership Tutorial series. In the last part I covered the basics of registering an account which would insert into a database. That part of the series was incredibly basic but touched on many different technologies which should have helped get you started. In this next part I&#8217;m going to look at logging in users that are registered into the database. If you would like a recap of Part 1 then please read <a href="http://rosstanner.co.uk/2011/03/user-membership-system-part-1-registration/">User Membership System Part 1: Registration</a>.</p>
<p>So, lets take a look at the database structure that we created in part 1:</p>
<p><a href="http://rosstanner.co.uk/wp-content/uploads/2013/02/database-structure.jpg"><img class="aligncenter size-full wp-image-499" alt="database-structure" src="http://rosstanner.co.uk/wp-content/uploads/2013/02/database-structure.jpg" width="453" height="67" /></a></p>
<p>As you can see we have two fields: <strong>username</strong> and <strong>password</strong>. What we need to do next is match any login attempts against the records in this table and if we find a match &#8211; with a valid password &#8211; then log the user in. Otherwise, we&#8217;ll need to display a message stating that their login was unsuccessful. But first, let us create a simple HTML login form.</p>
<pre name="code" class="html">&lt;html&gt;
&lt;head&gt;
	&lt;title&gt;Login&lt;/title&gt;
	&lt;script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"&gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
    &lt;link type="text/css" rel="stylesheet" href="style.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id="container"&gt;
		&lt;h1&gt;Login&lt;/h1&gt;
		&lt;div id="result"&gt;&lt;/div&gt;
		&lt;form method="post" onSubmit="return false;"&gt;
            &lt;table border="0"&gt;
                &lt;tbody&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Username: &lt;/td&gt;
                        &lt;td&gt;&lt;input type="text" name="username" id="username"&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;Password: &lt;/td&gt;
                        &lt;td&gt;&lt;input type="password" name="password"&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                    &lt;tr&gt;
                        &lt;td&gt;&lt;/td&gt;
                        &lt;td&gt;&lt;input type="button" name="login_submit" value="Submit" id="login-btn"&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/tbody&gt;
            &lt;/table&gt;
        &lt;/form&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Save this file as <strong>login.html</strong>. This should be pretty simple to understand. We just have a form which accepts two user inputs: username and password. Once the form is submitted it will use AJAX to run a PHP script which will check the credentials and return a response. Now lets setup the jQuery to perform this AJAX request.</p>
<p>Open up our already created <strong>script.js</strong> file and replace the whole content with the following code:</p>
<pre name="code" class="javascript">	
	$(function() {
		$("input[name='register_submit']").click(function(){

			var username = $("input[name='username']").val();
			var password = $("input[name='password']").val();

			$.ajax({
				type: "POST",
				url: "register.php",
				data: "username="+username+"&amp;password="+password,
				success: function(msg){
					$("#result").html ( msg );
				}
			});
		});

		$("input[name='login_submit']").click(function(){

			var username = $("input[name='username']").val();
			var password = $("input[name='password']").val();

			$.ajax({
				type: "POST",
				url: "login.php",
				data: "username="+username+"&amp;password="+password,
				success: function(msg){
					$("#result").html ( msg );
				}
			});
		});
	});</pre>
<p>You can see that an extra event function has been added. This event will listen to the login form submission and then send the data via AJAX to our login.php script, that we will now create. Save this file as <strong>login.php</strong>.</p>
<pre name="code" class="php">&lt;?php

	// -- store the posted data
	$username = $_POST['username'];
	$password = $_POST['password'];
	// -- check if the username or password was not entered
	if (empty ($username) || empty ($password)) {
		?&gt;&lt;div class="error"&gt;A field was left blank, try again.&lt;/div&gt;&lt;?php 
		exit;
	}

    // -- define the default valid state
	$valid = false;

	// -- require the database configuration file
	require 'config.php';

	// -- escape the posted username (to prevent SQL injection)
	$username = mysql_real_escape_string ($username);

	// -- query the database for a matching username
	$query_for_username = mysql_query ("SELECT username, password FROM users WHERE username = '".$username."' LIMIT 1", $conn);

	// -- check if a result exists
	if (mysql_num_rows ($query_for_username) == 1) {

		// -- the user exists
		// -- -- get the result of the query
		$user = mysql_fetch_assoc ($query_for_username);

		// -- check if the password is a match
		if ($user['password'] == sha1 ($password)) {

			// -- successful login
			$valid = true;

		}

	}

	// -- check if the form and user was successfully validated
	if ($valid === true) {

		// -- generate the user cookie
		setcookie ('username', $user['username']);
		setcookie ('password', $user['password']);

		?&gt;&lt;div class="success"&gt;You are now logged in. &lt;a href="dashboard.php"&gt;Proceed to your dashboard&lt;/a&gt;.&lt;/div&gt;&lt;?php

	} else {
		?&gt;&lt;div class="error"&gt;Invalid credentials supplied, please try again.&lt;/div&gt;&lt;?php
	}

	// -- close the open database connection
	mysql_close ( $conn );

?&gt;</pre>
<p>Although pretty clear within the comments what each line does, here is an overview:</p>
<ol>
<li>Get the posted Username and Password and store these in variables.</li>
<li>Check to see that both a username and password was entered.</li>
<li>Create a default container for the $valid variable. This, by default, is false until the user login is valid.</li>
<li>Connect to the database using the configuration file created in Part 1.</li>
<li>Escape the entered username. As this is user inputted data we need to be secure and protect ourselves against <a href="http://rosstanner.co.uk/2012/01/php-mysql-preventing-mysql-injection/">MySQL Injection</a>.</li>
<li>Query the database table for a user that matches the entered username.</li>
<li>If a user doesn&#8217;t exist, do nothing.</li>
<li>If a user does exist, fetch the record from the database table and match the passwords.</li>
<li>If the password does not match, do nothing.</li>
<li>If the password does match then the login was valid, so set the cookies.</li>
<li>If there was a problem with the credentials at any point, output the error message.</li>
<li>Finally, disconnect from the database.</li>
</ol>
<p>And that&#8217;s pretty much it. As we set most of the foundations in part 1, this step was much easier to just plugin and work as expected. Now your registered users can login using their credentials and upon success can go off to their dashboard &#8211; something I will cover in Part 3. Hope you&#8217;ve enjoyed this tutorial and any questions &#8211; just fire away!</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2013/02/user-membership-system-part-2-logging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wolf Fleeces &#8211; A New Trend? Tumblr decides.</title>
		<link>http://rosstanner.co.uk/2013/01/wolf-fleeces-trend-tumblr-decides/</link>
		<comments>http://rosstanner.co.uk/2013/01/wolf-fleeces-trend-tumblr-decides/#comments</comments>
		<pubDate>Fri, 04 Jan 2013 19:55:51 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[wolf fleece]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=481</guid>
		<description><![CDATA[<p>I&#8217;m a big fan of the Tumblr&#8217;s. Unfortunately in recent times it&#8217;s been flooded with young people talking about their favourite celebs and Twilight stars. It&#8217;s also been in a lot of trouble around suicide blogs and pornography. For me that&#8217;s not what it should be for.</p> <p>It should be for the likes of <a [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m a big fan of the Tumblr&#8217;s. Unfortunately in recent times it&#8217;s been flooded with young people talking about their favourite celebs and Twilight stars. It&#8217;s also been in a lot of trouble around suicide blogs and pornography. For me that&#8217;s not what it should be for.</p>
<p>It should be for the likes of <a title="YPLAC" href="http://youparklikeacunt.com/" target="_blank">YPLAC</a> and <a href="http://kimjongillookingatthings.tumblr.com/" target="_blank">Kim Jong-Il Looking At Things</a>. This gave me an idea and I&#8217;ve always wanted to do my own but the trends were either boring or have been covered before. I was going to do old ladies with perms wearing green coats. Now I&#8217;ve got you thinking&#8230; &#8216;Wow, there really are loads!&#8217; Yes there are, too many in fact. It&#8217;s also boring &#8211; who wants to see that rubbish.</p>
<p><img class="alignright" alt="wolf fleece" src="http://24.media.tumblr.com/tumblr_mem57bWXvg1rmpploo1_500.jpg" width="240" height="321" /></p>
<p>Then whilst out and about a colleague and we began to notice a rather large trend in &#8216;wolf fleeces&#8217;, not always in the autumn or winter months. What are these you ask? Well, take a look at <a title="Wolf Fleece" href="http://fuckingfleece.tumblr.com" target="_blanK">http://fuckingfleece.tumblr.com</a>. We started taking photographs just so that we could show the world the greatness that is the fleece. We have a few already &#8211; around ten or so &#8211; all from Gloucester! I looked around everywhere whilst on a recent trip to London (I didn&#8217;t go for this reason I should add) and I didn&#8217;t see any! Zilch! Is it a South-West England thing? It&#8217;s not that cold down here.</p>
<p>Take a look at the <a title="wolf fleece" href="http://fuckingfleece.tumblr.com" target="_blank">wolf fleece craze</a> that is sweeping the fashion world. If you see any of these fleece whilst on your travels then pop out your phone, grab a quick snap and send over to ross@rosstanner.co.uk so that I can get it up on the blog.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2013/01/wolf-fleeces-trend-tumblr-decides/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Build a simple contact form using HTML, PHP and Bootstrap</title>
		<link>http://rosstanner.co.uk/2012/11/build-simple-contact-form-html-php-bootstrap/</link>
		<comments>http://rosstanner.co.uk/2012/11/build-simple-contact-form-html-php-bootstrap/#comments</comments>
		<pubDate>Fri, 02 Nov 2012 15:23:00 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[contact form]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=463</guid>
		<description><![CDATA[<p>Hello and welcome to my newest tutorial: Build a simple contact form using HTML, PHP and Bootstrap. We will be building a simple contact form which will firstly validate the content posted then if successful, send an email with the details.<br /> Difficulty: Easy</p> <p>Before starting this tutorial I will assume you have a basic knowledge [...]]]></description>
				<content:encoded><![CDATA[<p>Hello and welcome to my newest tutorial: <strong>Build a simple contact form using HTML, PHP and Bootstrap</strong>. We will be building a simple contact form which will firstly validate the content posted then if successful, send an email with the details.<br />
<strong>Difficulty:</strong> Easy</p>
<p><em>Before starting this tutorial I will assume you have a basic knowledge of both HTML and PHP, and also have setup a working web directory. We will be working with the CSS framework <a title="Twitter Bootstrap" href="http://twitter.github.com/bootstrap/" target="_blank">Bootstrap</a> (by Twitter) to style the form.</em></p>
<p>Here is what we will ultimately be creating:  <a href="http://rosstanner.co.uk/p/contact-form/contact-form.php" target="_blank">View Demo</a></p>
<p>So, where do we start? Firstly we will want to create a HTML form which will post the user inputted data to our email address. Here is just a basic form which asks for a <strong>Name</strong>, <strong>Email Address</strong> and a <strong>Message</strong> to send, written using the Bootstrap classes.</p>
<pre name="code" class="html">
&lt;!DOCTYPE HTML>
&lt;html>
&lt;head>
	&lt;title>My basic contact form&lt;/title>
    &lt;link href="css/bootstrap.min.css" rel="stylesheet">
&lt;/head>
&lt;body>

	&lt;div class="container">
	
        &lt;div class="page-header">
            &lt;h1>Contact Me&lt;/h1>
        &lt;/div>
        &lt;form method="POST" action="contact-form-submission.php" class="form-horizontal">
            &lt;div class="control-group">
                &lt;label class="control-label" for="input1">Name&lt;/label>
                &lt;div class="controls">
                    &lt;input type="text" name="contact_name" id="input1" placeholder="Your name">
                &lt;/div>
            &lt;/div>
            &lt;div class="control-group">
                &lt;label class="control-label" for="input2">Email Address&lt;/label>
                &lt;div class="controls">
                    &lt;input type="text" name="contact_email" id="input2" placeholder="Your email address">
                &lt;/div>
            &lt;/div>
            &lt;div class="control-group">
                &lt;label class="control-label" for="input3">Message&lt;/label>
                &lt;div class="controls">
                    &lt;textarea name="contact_message" id="input3" rows="8" class="span5" placeholder="The message you want to send to me.">&lt;/textarea>
                &lt;/div>
            &lt;/div>
            &lt;div class="form-actions">
                &lt;input type="hidden" name="save" value="contact">
                &lt;button type="submit" class="btn btn-primary">Send&lt;/button>
            &lt;/div>
        &lt;/form>
        
    &lt;/div>
        
&lt;/body>
&lt;/html>
</pre>
<p>If you know how HTML forms work then you can see in the <strong>action</strong> attribute that the data will post to <strong>contact-form-submission.php</strong>. Different developers have different ways of posting data (you could use the same file) but for simplicity and cleanliness I&#8217;m going to post to a seperate file. The only issue is that if the form encounters an error, we have to redirect back to the form again, but you can always do things differently to suit your needs.</p>
<p>Let&#8217;s now create the PHP being the data capture and email sending. Create a new file and name it <strong>contact-form-submission.php</strong> and enter the following PHP code:</p>
<pre name="code" class="php">
&lt;?php

// check for form submission - if it doesn't exist then send back to contact form
if (!isset($_POST["save"]) || $_POST["save"] != "contact") {
    header("Location: contact-form.php"); exit;
}
	
// get the posted data
$name = $_POST["contact_name"];
$email_address = $_POST["contact_email"];
$message = $_POST["contact_message"];
	
// check that a name was entered
if (empty($name))
    $error = "You must enter your name.";
// check that an email address was entered
elseif (empty($email_address)) 
    $error = "You must enter your email address.";
// check for a valid email address
elseif (!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/", $email_address))
    $error = "You must enter a valid email address.";
// check that a message was entered
elseif (empty($message))
    $error = "You must enter a message.";
		
// check if an error was found - if there was, send the user back to the form
if (isset($error)) {
    header("Location: contact-form.php?e=".urlencode($error)); exit;
}
		
// write the email content
$email_content = "Name: $name\n";
$email_content .= "Email Address: $email_address\n";
$email_content .= "Message:\n\n$message";
	
// send the email
mail ("mail@example.com", "New Contact Message", $email_content);
	
// send the user back to the form
header("Location: contact-form.php?s=".urlencode("Thank you for your message.")); exit;

?>
</pre>
<p>This code may seem quite confusing to a new developer, so I&#8217;ll go through it line by line and explain what the hell is going on. </p>
<p>Firstly we will check that the parameter <strong>save</strong> is sent to this file. If it is, the form has been submitted but if it hasn&#8217;t then someone may be trying to access this file directly. If so, we want to redirect them to the form so that they can enter their details. The reason I am using a hidden record and not using the actual pressed button with a value is because older versions Internet Explorer doesn&#8217;t submit a button value with a form submit, which is a hassle. It&#8217;s much easier and more accessible to use a hidden field instead since that will always be posted, regardless of the broswer.</p>
<pre name="code" class="php">
if (!isset($_POST['save']) || $_POST['save'] != 'contact') {
    header('Location: contact-form.php'); exit;
}
</pre>
<p>Next we capture the posted fields and save them as variables:</p>
<pre name="code" class="php">
    // get the posted data
    $name = $_POST['contact_name'];
    $email_address = $_POST['contact_email'];
    $message = $_POST['contact_message'];
</pre>
<p>Now that we have the data, we can start checking that the user entered correct information. The next lines are form validation and it checks the following (in order):</p>
<ol>
<li>The name is not empty.</li>
<li>The email address is not empty.</li>
<li>The email address is in a valid format, e.g mail@example.com.</li>
<li>The message is not empty.</li>
</ol>
<p>If any of these are matched then an error message is saved in <strong>$error</strong>.</p>
<pre name="code" class="php">
// check that a name was entered
if (empty($name))
    $error = 'You must enter your name.';
// check that an email address was entered
elseif (empty($email_address)) 
    $error = 'You must enter your email address.';
// check for a valid email address
elseif (!preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/', $email_address))
    $error = 'You must enter a valid email address.';
// check that a message was entered
elseif (empty($message))
    $error = 'You must enter a message.';
</pre>
<p>Next we check if an error was found and if it was send the user back to the contact form and also append the error text to the URL, so that we can pick it up and display it on the other side.</p>
<pre name="code" class="php">
    // check if an error was found - if there was, send the user back to the form
    if (isset($error)) {
        header('Location: contact-form.php?e='.urlencode($error)); exit;
    }
</pre>
<p>Now we can begin sending the message because we&#8217;ve checked for errors and if we&#8217;ve reached this point then everything must be fine. Firstly we will set the content of the email message which simply contains the posted data. You can jazz this up how you like.</p>
<pre name="code" class="php">
// write the email content
$email_content = "Name: $name\n";
$email_content .= "Email Address: $email_address\n";
$email_content .= "Message:\n\n$message";
</pre>
<p>Once the content is set, let&#8217;s just send the email.Just change <strong>mail@example.com</strong> to the email address that you&#8217;d like to receive the message. The second parameter, <strong>New Contact Message</strong>, is the email subject. The third is the message that we set above. I haven&#8217;t supplied a fourth parameter (optional) which would set the email headers, such as content type, &#8220;from&#8221; address, &#8220;cc&#8221;, &#8220;bcc&#8221;, etc.</p>
<pre name="code" class="php">
// send the email
mail ("mail@example.com", "New Contact Message", $email_content);
</pre>
<p>Finally, send the user back to the form with a success message.</p>
<pre name="code" class="php">
// send the user back to the form
header('Location: contact-form.php?s='.urlencode('Thank you for your message.')); exit;
</pre>
<p>That&#8217;s all for the submission file. Now we just need to pick up the result on the original form, whether it be a success or an error. Here is the final version of the original form:</p>
<pre name="code" class="php">
&lt;!DOCTYPE HTML>
&lt;html>
&lt;head>
	&lt;title>My basic contact form&lt;/title>
    &lt;link href="css/bootstrap.min.css" rel="stylesheet">
&lt;/head>
&lt;body>

	&lt;div class="container">
	
        &lt;div class="page-header">
            &lt;h1>Contact Me&lt;/h1>
        &lt;/div>
&lt;?php

		// check for a successful form post
		if (isset($_GET['s'])) echo "&lt;div class=\"alert alert-success\">".$_GET['s']."&lt;/div>";

		// check for a form error
		elseif (isset($_GET['e'])) echo "&lt;div class=\"alert alert-error\">".$_GET['e']."&lt;/div>";

?>
        &lt;form method="POST" action="contact-form-submission.php" class="form-horizontal">
            &lt;div class="control-group">
                &lt;label class="control-label" for="input1">Name&lt;/label>
                &lt;div class="controls">
                    &lt;input type="text" name="contact_name" id="input1" placeholder="Your name">
                &lt;/div>
            &lt;/div>
            &lt;div class="control-group">
                &lt;label class="control-label" for="input2">Email Address&lt;/label>
                &lt;div class="controls">
                    &lt;input type="text" name="contact_email" id="input2" placeholder="Your email address">
                &lt;/div>
            &lt;/div>
            &lt;div class="control-group">
                &lt;label class="control-label" for="input3">Message&lt;/label>
                &lt;div class="controls">
                    &lt;textarea name="contact_message" id="input3" rows="8" class="span5" placeholder="The message you want to send to me.">&lt;/textarea>
                &lt;/div>
            &lt;/div>
            &lt;div class="form-actions">
                &lt;input type="hidden" name="save" value="contact">
                &lt;button type="submit" class="btn btn-primary">Send&lt;/button>
            &lt;/div>
        &lt;/form>
        
    &lt;/div>
        
&lt;/body>
&lt;/html>
</pre>
<p>That&#8217;s it! That will now send an email and return with a message, assuming all was OK. Any questions, fire away.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/11/build-simple-contact-form-html-php-bootstrap/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>PHP OOP Tutorial &#8211; Part 1: Introduction</title>
		<link>http://rosstanner.co.uk/2012/09/php-oop-tutorial-part-1-introduction/</link>
		<comments>http://rosstanner.co.uk/2012/09/php-oop-tutorial-part-1-introduction/#comments</comments>
		<pubDate>Tue, 11 Sep 2012 18:53:52 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[classes]]></category>
		<category><![CDATA[methods]]></category>
		<category><![CDATA[oop]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=449</guid>
		<description><![CDATA[<p>Before you start, this tutorial will assume you have at least basic knowledge of PHP.</p> <p>At the time of writing this post I am approaching 4 years of professional experience as a PHP developer and I&#8217;ve just turned 23. I started developing at a young age but not necessarily early into the development of the [...]]]></description>
				<content:encoded><![CDATA[<p><em>Before you start, this tutorial will assume you have at least basic knowledge of PHP.</em></p>
<p>At the time of writing this post I am approaching 4 years of professional experience as a PHP developer and I&#8217;ve just turned 23. I started developing at a young age but not necessarily early into the development of the PHP language. I found that OOP (Object Orientated Programming) has taken off massively since the release of PHP5 although it was around as early as PHP3. It was re-written for PHP5 and along came a lot of improvements and enhancements which had brought about the modern websites, frameworks and technologies that we see today. If you&#8217;ve read my blog before then you&#8217;d know I&#8217;m familiar with CodeIgniter and it is by far my favourite framework simply because it is very lightweight and incredibly easy to learn.</p>
<p>CodeIgniter uses the MVC (Model-View-Controller) structure and has become widely popular. It&#8217;s system is built on core object orientated programming and has led me to learn more and more about how exactly this works. I wouldn&#8217;t consider myself an OOP expert, far from it, but I&#8217;ve learnt more than enough to provide you with an insight into how it works and the benefits. Feel free to shoot me down on anything you consider incorrect because I myself am still on that learning curve.</p>
<p>So, what is OOP? I&#8217;ve already mentioned that it stands for Object Orientated Programming which pretty much sums it up. It&#8217;s a way of coding PHP using objects, like a hierarchy in essence. It&#8217;s probably not needed for smaller projects but for large, heavy and data intensive programs it works wonders. It will help you organise your code into sections so that each method will do it&#8217;s own job. You will find your code much easier to read and you won&#8217;t have to repeat things over and over. You&#8217;ve probably come across functions before and you know how useful they are, but this is a whole different ball game.</p>
<p>Let&#8217;s start by diving in at the deep end and creating our first project using this structure. The first thing to do is to create a &#8220;class&#8221;. I like to consider these as parents and children (in the real world). First of all you need to speak to the parent then if the parent allows it, speak to the children. Sometimes the parent won&#8217;t allow you to ask the child certain things, but can ask for you in some cases. It&#8217;s quite confusing so let&#8217;s see it in action:</p>
<pre name="code" class="php">
<;?php

class Sim {
	
    public $hunger = 10;
    public $bladder = 1;
    public $sleep = 10;
    public $hygiene = 10;
    public $social = 10;
    public $fun = 10;
	
    public function Create()
    {
        echo "Sim Created<br />";
    }

    public function Toilet()
    {
        $this->bladder = 10;
        echo "Sim uses the toilet, bladder now empty.<br />";
    }
	
}

?>;
</pre>
<p>Everyone has played The Sims, right? In this class there are several variables each representing an attribute of a certain Sim. Each Sim has 10 points for hunger, bladder, sleep, hygiene, social and fun but in this case the Sim has only 1 point for bladder. This means we must send the Sim to the toilet or risk him/her wetting themselves!</p>
<p>This is quite a simple class and it contains two methods: Create() which creates a new Sim and Toilet() which will send the Sim to the toilet to empty his/her bladder. By using the toilet we will need to alter the variable for their bladder from 1 to 10. You could extend the class by using specific types of toilets which will empty less of the bladder and such like, but that would be more advanced.</p>
<p>Lets now start using the class:</p>
<pre name="code" class="php">
<;?php

class Sim {
	
    public $hunger = 10;
    public $bladder = 1;
    public $sleep = 10;
    public $hygiene = 10;
    public $social = 10;
    public $fun = 10;
	
    public function Create()
    {
        echo "Sim Created<br />";
    }
	
    public function Toilet()
    {
        $this->bladder = 10;
        echo "Sim uses the toilet, bladder now empty.<br />";
    }
}

$Sim = new Sim();
$Sim->Create();
echo "Bladder: ".$Sim->bladder."<br />";
$Sim->Toilet();
echo "Bladder: ".$Sim->bladder."<br />";

?>;
</pre>
<p>Run this file in your browser and you should see the following results:</p>
<pre name="code">
Sim Created
Bladder: 1
Sim uses the toilet, bladder now empty.
Bladder: 10
</pre>
<p>You can see that first of all we initiated the class. This basically just loads the class ready for what we need to do and returns the object into the variable $Sim. Then we created the Sim by calling that specific method, and this told us &#8220;Sim Created&#8221;.</p>
<p>The next part is where it can perhaps get confusing. We are accessing an object variable which is part of the class and you&#8217;ll notice it doesn&#8217;t contain parenthesis as it isn&#8217;t a function/method. This variable is updated by us sending the Sim to use the toilet and is reset to 10 points. This is output on the next line.</p>
<p>That is the basics of OOP as it&#8217;s most basic level. It can be taken a lot further but hopefully you can get to start using classes and methods and it will become a good starting point.</p>
<p>Any questions feel free to comment below.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/09/php-oop-tutorial-part-1-introduction/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>New Portfolio Item: First4Castles</title>
		<link>http://rosstanner.co.uk/2012/08/portfolio-item-first4castles/</link>
		<comments>http://rosstanner.co.uk/2012/08/portfolio-item-first4castles/#comments</comments>
		<pubDate>Thu, 02 Aug 2012 21:57:49 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[Portfolio]]></category>
		<category><![CDATA[bouncy castle]]></category>
		<category><![CDATA[cheltenham]]></category>
		<category><![CDATA[first4castles]]></category>
		<category><![CDATA[gloucester]]></category>
		<category><![CDATA[portfolio]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=441</guid>
		<description><![CDATA[<p>It&#8217;s been a while since I last blogged (I seem to say that on every post!) so I thought I&#8217;d update you on what&#8217;s been going on for the last few months. I&#8217;ve been working hard behind the scenes for numerous freelance clients and I am going to show you what I have built for [...]]]></description>
				<content:encoded><![CDATA[<p>It&#8217;s been a while since I last blogged (I seem to say that on every post!) so I thought I&#8217;d update you on what&#8217;s been going on for the last few months. I&#8217;ve been working hard behind the scenes for numerous freelance clients and I am going to show you what I have built for one of them. This is a bouncy castle hire company based in my home town of Gloucester, UK and is the first full completed website that I have added to my online portfolio.</p>
<div id="attachment_442" class="wp-caption alignleft" style="width: 360px"><a href="http://rosstanner.co.uk/wp-content/uploads/2012/08/first4castles.jpg"><img class="size-full wp-image-442" title="First4Castles" src="http://rosstanner.co.uk/wp-content/uploads/2012/08/first4castles.jpg" alt="Bouncy Castle Hire Gloucester" width="350" height="361" /></a><p class="wp-caption-text">First4Castles.co.uk &#8211; Bouncy Castle Hire Gloucester</p></div>
<p>The site was built using CodeIgniter a PHP framework that is a massive favourite of mine and takes advantage of the wonderful Twitter Bootstrap that seems to work perfectly for any project I come to take on. It was built with SEO in mind and uses the keywords <a title="Bouncy Castle Hire Gloucester" href="http://www.first4castles.co.uk" target="_blank">bouncy castle hire Gloucester</a> and <a title="Bouncy Castle Hire Cheltenham" href="http://www.first4castles.co.uk" target="_blank">bouncy castle hire Cheltenham</a> although they do also have a range of <a title="Party Marquees for hire" href="http://www.first4castles.co.uk/marquees-for-hire.html" target="_blank">party marquees for hire</a> too.</p>
<p>So, if your local to me and have a party coming up soon then pay these guys a visit. Excellent service and competitive rates and they guarantee a good time!</p>
<p>Website: <a title="First4Castles" href="http://www.first4castles.co.uk/" target="_blank">First4Castles.co.uk</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/08/portfolio-item-first4castles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing XML using PHP SimpleXML</title>
		<link>http://rosstanner.co.uk/2012/05/parsing-xml-php-simplexml/</link>
		<comments>http://rosstanner.co.uk/2012/05/parsing-xml-php-simplexml/#comments</comments>
		<pubDate>Fri, 18 May 2012 15:50:35 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[parse xml]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[simplexml]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLReader]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=428</guid>
		<description><![CDATA[<p>XML is amazing for transferring data between two systems and I use it on a daily basis. It took me a while to understand the need for it but once you start using XML, web services, APIs and general development will become clear to you. Today I will walk you through the basics of SimpleXML [...]]]></description>
				<content:encoded><![CDATA[<p>XML is amazing for transferring data between two systems and I use it on a daily basis. It took me a while to understand the need for it but once you start using XML, web services, APIs and general development will become clear to you. Today I will walk you through the basics of SimpleXML and how it can help you parse XML to make your applications more efficient.</p>
<p>Firstly you need to be aware of a downside to SimpleXML and this is that it is not very efficient for large XML files (when I say large I&#8217;m talking hundreds of megabytes and above). This is because SimpleXML will load the entire into XML document into memory before parsing it. So, you either need to increase PHP&#8217;s memory limit (not always advised) or use an alternative method, such as <a title="XMLReader" href="http://www.php.net/manual/en/book.xmlreader.php">XMLReader</a>.</p>
<p>Lets take a very simple XML document which happens to be called <strong>data.xml</strong>:</p>
<pre name="code" class="xml">    &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;products&gt;
        &lt;product&gt;
            &lt;id&gt;1&lt;/id&gt;
            &lt;name&gt;Apple iPhone&lt;/name&gt;
            &lt;price&gt;500.00&lt;/price&gt;
        &lt;/product&gt;
        &lt;product&gt;
            &lt;id&gt;2&lt;/id&gt;
            &lt;name&gt;BlackBerry Curve&lt;/name&gt;
            &lt;price&gt;250.00&lt;/price&gt;
        &lt;/product&gt;
        &lt;product&gt;
            &lt;id&gt;2&lt;/id&gt;
            &lt;name&gt;Samsung Galaxy S&lt;/name&gt;
            &lt;price&gt;340.00&lt;/price&gt;
        &lt;/product&gt;
    &lt;/products&gt;</pre>
<p>You can see that there are a list of products and there are 3 individual items inside this tag. What we will do is load this file into SimpleXML which will convert into an object which we can then use for our application. Here is how we do this:</p>
<pre name="code" class="php">    &lt;?php

        // load the XML document into an Object
        $xml = simplexml_load_file ( "data.xml" );

    ?&gt;</pre>
<p>We now have our XML into an object which is stored in the variable <strong>$xml</strong>. If we output this to the browser we will see the following:</p>
<p><center style="clear: both; margin: 10px 0;"><a href="http://rosstanner.co.uk/wp-content/uploads/2012/05/simplexml.png"><img class="size-full wp-image-429 aligncenter" title="SimpleXML" src="http://rosstanner.co.uk/wp-content/uploads/2012/05/simplexml.png" alt="SimpleXML" width="390" height="458" /></a></center>This makes it much easier to see what&#8217;s going on in our XML document and it splits up quite well. We can see here that there are 3 products and also that each have an ID field, a name and price. Now let&#8217;s start parsing this data:</p>
<pre name="code" class="xml">
    &lt;?php

        // load the XML document into an Object
        $xml = simplexml_load_file ( "data.xml" );

        // loop through each product
        foreach ( $xml-&gt;product as $product ) {

            // output the product information
            echo "&lt;p&gt;";
            echo "&lt;strong&gt;".$product-&gt;name."&lt;/strong&gt;&lt;br /&gt;";
            echo "£".$product-&gt;price."&lt;/p&gt;";

        }

    ?&gt;</pre>
<p>Now you will see each product being output with the price beneath. This is just a simple example of parsing XML but of course there is much more you can do like build web services and such like. You would probably store the data into a database and output it that way as opposed to loading the XML on the fly, but it reallt depends on the application.</p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/05/parsing-xml-php-simplexml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Understanding functions in PHP</title>
		<link>http://rosstanner.co.uk/2012/05/understanding-functions-in-php/</link>
		<comments>http://rosstanner.co.uk/2012/05/understanding-functions-in-php/#comments</comments>
		<pubDate>Tue, 01 May 2012 20:30:04 +0000</pubDate>
		<dc:creator>Ross Tanner</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[repeating code]]></category>

		<guid isPermaLink="false">http://rosstanner.co.uk/?p=413</guid>
		<description><![CDATA[<p>Well it&#8217;s been a while since I last posted so I needed to get back into it somewhat quickly and easily. No easier way than writing a quick PHP tutorial which will also help fellow both professional and freelance web developers.</p> <p>In today&#8217;s tutorial I am going to teach you how to create a function [...]]]></description>
				<content:encoded><![CDATA[<p>Well it&#8217;s been a while since I last posted so I needed to get back into it somewhat quickly and easily. No easier way than writing a quick PHP tutorial which will also help fellow both professional and freelance web developers.</p>
<p>In today&#8217;s tutorial I am going to teach you how to create a function in PHP. Functions are incredibly useful because they help organise your code, prevent repetitive coding and are the foundations behind a decent codebase. I use PHP functions in everyday coding and so do you, probably without even realising it. PHP has a number of built-in functions which you would have been using all the time, from strtolower() to mysql_connect() or perhaps even as advanced as preg_match(). Each function has it&#8217;s own use and as you learn more PHP you will become familiar with both built-in functions and making your own.</p>
<p>Before you go about creating functions there are a couple of questions that you need to ask yourself first:</p>
<ol>
<li>is there a function that already does what I want to do?</li>
<li>do I need to create a function? i.e is this code going to be repeated?</li>
</ol>
<p>If you still feel you need to create one then here is how you go about doing it. My example is incredibly simple and will basically take any number you pass through and multiply it by 5.</p>
<pre name="code" class="php">
&lt;?php
    function multiply_number ( $mynum )
    {
        $mynum = ( $mynum * 5 );
        return $mynum;
    }
?&gt;
</pre>
<p>You can see here that I have declared a new function called <strong>multiply_number</strong> and I am picking up whatever number is passed to the function. I am storing this passed number as <strong>$mynum</strong> and then multiplying that amount by 5 before returning the result. There are two clear benefits here:</p>
<ol>
<li>if I wanted to change 5 to any other number I can do it easily by changing it in only one place</li>
<li>if I am multiplying several numbers by 5 then its easier to keep calling this function rather than writing it out each time</li>
</ol>
<p>So, when we go about calling this function several times we can do it easily as follows:</p>
<pre name="code" class="php">
&lt;?php
    echo multiply_number(1);
    echo multiply_number(10);
    echo multiply_number(145);
    echo multiply_number(1563654);
    echo multiply_number(1.2);
?&gt;
</pre>
<p>I&#8217;m calling the function each time but just passing a different number. As the number is changing so will the result and this will be shown once the script has run. You could even expand this by passing a second number to the function and this number replaces the 5 &#8211; the number multiplied against.</p>
<p>Functions are incredibly useful and are a fundemental part of any master coder&#8217;s work, especially as you go into OOP (Object Orientated Programming) and the MVC (Model-View-Controller) structure.</p>
<p>I hope you found this useful. Please feel free to ask any questions or leave a comment below. <strong>Before anyone says &#8216;it would be quicker to just do the math each time&#8217; then yes, you are right. This is a very basic example of how functions can be used but as you keep developing you will learn to only use them when you know the time is right.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://rosstanner.co.uk/2012/05/understanding-functions-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
