Building An Affiliate Portal Website

By: John Elder posted in Affiliate Portals


Hello good people!

Alright! It’s time to dive right into this new project! I’m calling it the affiliate portal project…because we’re going to be building a sort of web portal, or shopping search engine. The time for talk is over, let’s dive right in!

Step One: Pick a domain name. When you build a large shopping portal or price comparison site, you want a short name that’s as memorable as possible. And it should definitely be a .com domain name.

I’ve owned whythere.com since 2002. I built a crappy search engine on it way back then, but it never really caught on…I didn’t really put any effort into it (I think I used a third party perl script to run it).

So we’re going to use whyThere.com for this project. Why that name? No reason. It’s short, I own it already, and I’m not using it for anything at the moment!

Maybe one of you can come up with some cheezy slogan for it…”Shopping? Why There!?” I dunno…whatever.

First Things First!

So I’m going to start off by just throwing up a VERY simple landing page for the front page of the site. Just a search box and a button. Don’t worry, we’ll work on making it look nice later. For now we’ll just get the bare bones up and running and go from there.

Today I’ll just talk about that search box, and the php code that goes into running it, and how we can pass what a person types into it into a variable that we can then use to autogenerate the following page.

Sound good? Good.

So head over to WhyThere.com and check it out. Type in a product…like vacuum cleaner…or lawn mower.

Note: One thing to note…I’ve set up a cache (I’ll explain cache later) to only accept so many simultaneous searches at a time. So after I publish this article, a bunch of you may go to the site and start poking around…and the cache may stop you. I’ll tinker with this later. If it happens to you, just try back at the top of the next hour and the cache will have reset itself.

If you want to make sure to see results, type in vacuum cleaner and it should work no matter what. That and chainsaw are both cached to show no matter what.

Ok…back to the main page.

Basically when you click the search button, it calls a file called search.php that I wrote myself.

Search.php

Here’s the contents of search.php

<?php
$search = trim($_POST['search']);
?>

<html>
  <head>
        <title>
          WhyThere.com | Search Results
        </title>
	</head>
	<body>
	<center>
	<br>

<h1><font size="10" color="#003660">WhyThere.com</font></font></h1>
<font size="2" face="arial">The Lowest Prices For The Things You Love</font>
<br><br><br>

<form method="post" action="search.php">
<input type="text" name="search" size="75" class="searchbox" maxlength="600" />
<input type="submit" name="submit" value="Search For Lowest Prices" />
</form>


<br><br>
<table border="0"><td><td width="700">
<?php
$options = array();
$options["keywords"] = $search;
$options["searchindex"] = "All";
$options["country"] = "US";
$options["trackingid"] = "intrmedi-20";
$options["sort"] = "none";
$options["templatename"] = "default";
$options["paging"] = "false";
require_once(dirname(__FILE__) . "/phpzon/phpzon.php");
phpZonAPI($options);
?>
</td></tr></table>

<br>
<form method="post" action="search.php">
<input type="text" name="search" size="75" class="searchbox" maxlength="600" />
<input type="submit" name="submit" value="Search For Lowest Prices" />
</form>

<br><br>
Copyright © Flatplanet Media, LLC - All Rights Reserved
<br><br>

</body>
</html>

This is just some simple html and php code, and basically all we’re doing here is passing the contents of the form from the main page into a variable. Once we have that variable, we can do whatever we want with it. In this case, we’re going to take that variable and use it to dynamically generate the search results page.

It’s pretty simple and straight forward (as far as coding goes)…and once you understand how to do it, you can use php for just about anything when it comes to making affiliate websites.

In our case I’m going to pass that variable into my copy of phpZon. I’ve talked about phpZon here in the past, it’s a great tool for returning targeted products from amazon’s affiliate program.

In the future, we’ll add LOTS more functionality and different results to our search results script…but for now I’m just going to have it return phpZon results.

Soon I’ll program in some price comparison functionality and some other cool stuff…but this is day one and we’re keeping it simple.

So back to the code…notice the very first line:

<?php
$search = trim($_POST['search']);
?>

That’s the most important line here. What that does is pass whatever a person typed into the search form on the main page, to our server. It then takes that search string and passes it into the variable $search.

The other important thing is the next bit of php code:

<?php
$options = array();
$options["keywords"] = $search;
$options["searchindex"] = "All";
$options["country"] = "US";
$options["trackingid"] = "intrmedi-20";
$options["sort"] = "none";
$options["templatename"] = "default";
$options["paging"] = "false";
require_once(dirname(__FILE__) . "/phpzon/phpzon.php");
phpZonAPI($options);
?>

That’s just the default code that you use to fire up phpzon. Take a look at it. Most of it is completely unimportant. But see the line $options[“keywords”] = $search; ?? See that $search variable? That’s the same search variable we created at the top of the page. That’s how we pass whatever a person typed into the search box over to phpzon.

The website looks pretty bad!

Ok…up till now the search results page looks pretty ugly. The search results are all jumbled together, and amateurish.

We’ll work on prettying it up next time.

But we’re off and running! Stay tuned, and…

Keep on building!

-John
The Marketing Fool!

John Elder is an Entrepreneur, Web Developer, and Writer with over 27 years experience creating & running some of the most interesting websites on the Internet. Contact him here.



Did you like this article? Share it:


No comments.

Leave a Reply