Affiliate Marketing 101: How to Do It



A little while ago, I wrote a post about affiliate marketing, and what it is. This follows on from that one, and we’ll be looking here about how you can get started as an affiliate, what markets to look at, and how you can make some money from it. I’ll also do another post in a couple of days looking at how you can take this further.

All About Passion

I think the basic stumbling block most people face when they get started in affiliate marketing is they want to make money. Sounds odd, but stick with me on this one. Most of the really successful affiliate marketers I know didn’t get into the game thinking “I’m going to make a shedload of money off affiliate marketing.” Instead, they created a site about a topic they knew about and were passionate about, and at some point later in the game, they looked into ways to monetise it, and wound up using affiliate marketing as a method of doing that.

The key thing to note here is that they weren’t setting out to build and affiliate site. Many of them then went on to do that later, but they applied what they knew from already having one successful site first. And there’s the difference.

Their starting point is generally “What do I have a passion for, that I can write about?”, not “What has a really good CPL payout?” or “What is hot in search numbers at the moment?”. When you get into this, do it for the right reasons: you want to create a really awesome site, that will be monetisable. Anything else is the wrong reason (because aside from anything else, you might discover that affiliate marketing isn’t the best monetisation method long term for whatever the niche is).

Creating Some Content

Once you’ve picked your niche, you’ll have to create a website. I’ll go into that some other time (we’ll be doing a series of posts on building a site and site design and all that malarkey in the future), because it’s too big a topic to cover here. Instead, what we’ll look at now is content creation.

The first thing that you’re going to need to do is start building content on your site, to start generating some traffic. What I’d suggest for this is that you find all the big blogs in the niche you’re going into, and see what posts have the most comments, see what they’re writing on, what topics come up over and over again. This is going to give you some idea as to what the community is interested in. From here, you can start creating your own content.

To start doing that, I’d suggest you pick ten separate topics in your niche, and write a post on each one. This will do two things:

  1. Show you whether you actually have an interest in whatever the subject is, because if you get bored of talking about it, it’s probably not the right niche for you, and
  2. Give you a solid base to build your site off

Now, you could get around this by going down the outsourcing route, but really I’d suggest that if you’re not that interested in whatever your site is, then that’ll come across, and other people won’t be interested in it either.

One Inch Wide and Ten Miles Deep

The final thing I’ll say in this post is, with everything you write, make sure you’re writing about the right things. As a general rule, the tighter you focus on your market, the better you’ll do. Now, I don’t mean with this that you should only stick to one topic, but instead only write on topics that your audience will be interested in.

As an example, our blog has a readership composed of mainly web and tech related readers. They’re interested in marketing, programming, web design, and other such digital things. So we cover those topics. We don’t focus on one idea obsessively, we focus on one market obsessively. You need to do the same. Talk about the things your audience are interested in. So if your site is on Star Trek, you could probably talk about other sci-fi shows too, because you’re talking about a sub-niche of a broader niche (Star Trek in the sci-fi niche). You’d probably do well to write about Battlestar Galactica, Red Dwarf, Star Wars and other such things. Similarly, if you write about computer components, you could probably branch out to talk about gadgets and technology in more general terms. Again, the audience is interested in those things too.

The key with creating a site people want to visit is creating content people want to see. As long as you focus on your audience obsessively, you can’t go far wrong.

Onwards and Upwards

In the next post in this series, we’ll look at how to pick products to promote, and how to promote them without pissing people off. Until then, if you’ve got any questions, leave a comment below and we’ll try and help out!

PHP For Dummies Part 3: It’s All About Your Form



In the last part we looked at the maths functions in PHP, and by extension, most of the operators. What we’re looking at today is form building. This is where we start to put the sexy in PHP. Using forms we can send data to databases, process inputs, check things, and generally just do stuff.

With that in mind, let’s take a look at basic form building…

Straight Spine, Shoulders Back

In this first example, we’re going to build a form that will take some text that a user has entered and output it on the next page. This is about as simple as you can get, but it forms the basis of 99% of the forms you’ll build using PHP. Others may use more complex scripts, or do more processing on the data, but the principle is the same: enter data, do something with it, output something.

Now let’s build some code. The first part is going to be the html for the form, which we’ll call form.html (original, I know).

<html>
<head>
	<title></title>
	<meta name="description" content=""/>
	<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
	<div id="wrapper">
		<form action="send.php" method="post">
			<label for="input" class="label">Enter your message:</label>
			<input type="text" name="message" size="30">
			<input type="submit" value="Send" class="button"> 
		</form>
	</div>
</body>
</html>

And the CSS file we’re creating, style.css, should look like this:

#wrapper { width: 300px; margin: 0 auto; padding: 50px 0 0; }
.label { display: block; float: left; width: 150px; }
.button { font-size: 0.9em; padding: 4px; color: #333; background-color: #eee; border: 1px solid #999; text-align: center; }

So what we’ve done so far is:

  • Create a basic form in HTML
  • Tell it to use the script send.php to process it, and
  • Style it with CSS

What we need to do now is create the send.php file, so it’ll actually do something. So let’s do that!

Processing, Processing

The following is the script send.php, which we told the form to use in form.html.

<?php
// Get the data from the form...
$data = $_POST['message'];
 
// ...and output it
echo "Confucius, he say: \"<i>$data</i>\"";
?>

What this does is say create a variable called data, and then give it the value of whatever is in the field called ‘message’. It then takes this variable and says print the following message: ‘Confucius, he say ‘ followed by whatever is in the data variable. So if we submitted the message ‘Your Mum!’, then the output would be ‘Confucius, he say: Your Mum!’.

PHP actually supports both Get and Post methods of submission. To use Get instead, you’d change the method (in form.html) from post to get, and retrieve the values by changing $_POST to $_GET in send.php. The reasons why you’d want to do this will be discussed when we cover arrays, later on.

And Now For Something Completely Different

Actually, that’s a lie. It’s pretty much the same. Only this time, we’re going to have a more intelligent form.

First off, let’s create the new form. This is basically the same as the one before, except we call the value we’re inputting ‘guess’.

<html>
<head>
	<title>Deep Thought</title>
	<meta name="description" content="Calculates the answer to life, the universe and everything"/>
	<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
	<div id="wrapper">
		<form action="deepthought.php" method="post">
			<label for="input" class="label">Enter a number:</label>
			<input type="text" name="guess" size="30">
			<input type="submit" value="Is it the answer?" class="button"> 
		</form>
	</div>
</body>
</html>

We’ll use the same style.css file we used before. Which means all that’s left to do is create the actual script to process the form again. This time, it’s called deepthought.php. Before we create it though, here’s a short description of what it should do.

The form, if all goes well, should take the number that we’ve input, and compare it to a given value. If it’s lower, it should say “This is NOT the answer to Life, The Universe and Everything. It’s too small!”. If it’s bigger, it should say “This is NOT the answer to Life, The Universe and Everything. It’s too big!”. And if it’s the same, it should say “Congratulations! You’ve found the answer to Life, The Universe and Everything!!!”

Now we know what we’re going to build, let’s build it!

<?php
// Assign the answer to Life, The Universe and Everything
$answer = 42;
 
// Get the data from the form...
$guess = $_POST['guess'];
 
// Check the guess against the answer, and tell us what you think, oh might Deep Thought
if ($guess > $answer) {
	echo "This is NOT the answer to Life, The Universe and Everything. It's too big!";
	}
elseif ($guess < $answer) {
	echo "This is NOT the answer to Life, The Universe and Everything. It's too small!";
	}
elseif ($guess = $answer) {
	echo "Congratulations! You've found the answer to Life, The Universe and Everything!!!";
	}
else {
	echo "You entered something that wasn't a number, you moron!";
	}
?>

Heer, we’re using the if, elseif and else statements to create our answer. We build if and elseif statements using the following syntax:

(value1 operator value2) { do something here }

…however, else statements just get

{ do something here }

…as they aren’t having to compare anything.

As such, this script is doing exactly whatit looks like. If you’re feeling a bit slow however, here’s the logic:

  1. Set The Answer as 42
  2. Get the person’s number, and call it ‘guess’
  3. Check if guess is more than answer, output the first response
  4. If that wasn’t right, then check if guess is less than answer, output the second response
  5. If that wasn’t right, then check if guess is the same as the answer, output the third response
  6. If none of those were right, then point out that they didn’t enter a number and insult them

Note that you don’t need to have elseif or even else statements to make these work. The else simply provides a default value. As such, we could just run four if statements.

Moving Onwards

Tomorrow we’ll take a look at some more operators, scripts and controls, and build some more wild and wonderful things using control structures.

PHP For Dummies Part 2: Do the Maths



In this second part of our tutorial series, we’re going to look at the maths functions PHP includes. In the third, we’ll look at forms.

Calculate This!

When you get right down to it, most PHP scripts, forms or functions are doing maths. It might not always be with numbers, but the principles remain the same. As such, a good working knowledge of PHPs maths operators is a good idea. So let’s look at an example, and see what it’s doing.

<?php
//How many units we had
$total = 1000;
 
//How many units we sold
$sold = 15;
 
//How many units we have now
$newtotal = $total - $sold;
 
//How many units are arriving tomorrow
$incoming = 25;
 
//How many units will we have tomorrow
$futuretotal = $newtotal + $incoming;
 
// How many did we sell, as a percentage of our incoming stock?
$difference = $incoming / $sold;
 
//And if we sold the same number every day for 21 days without restock, how many would we have?
$multiplied = $futuretotal - ($sold * 21);
?>

As you can see in the code above, we’re assigning values for a basic stock keeping system. We’ve got how many units of something we had in stock, how many we’ve sold, and then we’ve calculated how many we’ll have now, by taking away one from the other. We’ve then gone on to add new stock, work out how much we sold compared to what we’ve got coming in, and predict future stock levels.

With all these, the important thing to remember is to space things out. You should have a space before and after every operator (+, -, /, * etc).

You can also run some things simultaneously. For instance, rather than writing the following:

<?php
$a = 10;
$b = 15;
 
$a = $a + ($b - ($a - 2));
?>

…which would change the value of a to be 17, we can write…

<?php
$a = 10;
$b = 15;
 
$a += $b - ($a - 2);
?>

…instead. Not only is this easier to read, due to needing fewer brackets, it’s also a huge boon when you’re working with very large scripts, as you can trim down the time taken to write and debug them. It’s a bit counter-intuitive at first, but you get used to it!

Concatenation? Something to do with cats…

Concatenation is a long word that basically means adding two things together, but not in value. The operator for it is the period symbol. However, as this description sucks, I’ll illustrate it with an example that should help.

<?php
$a = 'Concat';
$b = 'enation';
 
$sentence = $a . $b;
 
echo $sentence;
?>

This would print out Concatenation. Another example would be:

<?php
$a = 'This';
$b = 'is';
$c = 'concatenation!';
 
$sentence = $a.$b.$c;
 
echo $sentence;
?>

When run, this would print out This is concatenation!. However, with this one, we can introduce an important change to make things faster.

Unfortunately, when you run the above script, PHP does a new concatenation for every period. This means we’re doing four separate concatenations. However, there is a faster way. If we reform this statement to look like:

<?php
$a = 'This';
$b = 'is';
$c = 'concatenation!';
 
$sentence = "$a $b $c";
 
echo $sentence;
?>

…that, then PHP actually does the whole thing in one go. This way, we also get to add the spaces directly into the string, which makes it easier to read too.

Take Care While Operating

If you want to know all the operators and what they do, here’s the list:

Operator Function
= Assignment
= Assignment
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulus (Remainders. 10 % 7 = 3 etc)
++ Increment
+= Increment Assignment
-= Decrement Assignment
*= Multiply Assignment
. Concatenate
() Parenthese (Do what’s in this first)
! Not
== Equals
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
!= Not equal
&&

and
Both statement $a && $b are true
||

or
Either statement $a || $b is true.
xor Exclusion or (Either one or other is true, not both)