| Tweet | ||
| Pin It |
The next step in building a datafeed website is getting the data into the database, but to do this, we need to build an administrative section to your website, and add some helper functions & files.
vars.php was a file seen in Step 1, which I use to store the mysql connection and other variables. Here’s a simplified version of the one I’m using:
<?php
// MySQL
$DB_NAME = 'your_db_name';
$DB_USER = 'your_db_username';
$DB_PASSWORD = 'your_db_password';
$DB_HOST = 'your_db_host';
mysql_connect($DB_HOST, $DB_USER, $DB_PASSWORD);
mysql_select_db($DB_NAME);
// Your ShareASale ID
$nSASID = 132296;
// Shortcut / Alias
function myres($cString) {
return mysql_real_escape_string(stripslashes($cString));
} // ends function mres($cString)
?>
Change lines 3-6 and 12.
Next, you’ll need to set-up an admin.php page, like so:
<?php
include('./vars.php');
include('./admin-password.php');
$bNavHome = true;
include('./header.php');
?>
<div class="post">
<h2 class="title">GreenWhiteAndBlackTea.com Admin</h2>
<div class="entry">
<ul>
<li><a href="admin-sas-datafeed.php">Upload ShareASale Datafeed</a></li>
</ul>
</div>
</div><!-- ends class="post" -->
<?php
include('./footer.php');
?>
Change as necessary – this is just an index for your admin section.
and admin-password.php:
<?php
if (!$_SERVER['PHP_AUTH_USER']) {
Header("WWW-authenticate: basic realm=\"" . $_SERVER['HTTP_HOST'] . " Admin\"");
Header("HTTP/1.0 401 Unauthorized");
exit;
}
else {
if (($_SERVER['PHP_AUTH_USER'] == 'the-username-you-want')
&& ($_SERVER['PHP_AUTH_PW'] == 'ssssshhhhh-super-secret')) {
// OK!!!!
$_SESSION['bAdmin'] = true;
;
}
else {
Header("WWW-authenticate: basic realm=\"" . $_SERVER['HTTP_HOST'] . " Admin\"");
Header("HTTP/1.0 401 Unauthorized");
echo("Login failed.\n");
exit;
}
}
?>
Set your username & password that you’d like on lines 8 & 9
Finally, in your MySQL database, create the products table:
CREATE TABLE `products` ( `ProductID` int(10) unsigned NOT NULL, `Name` varchar(255) NOT NULL, `MerchantID` int(10) unsigned NOT NULL, `Merchant` varchar(255) NOT NULL, `Link` varchar(255) NOT NULL, `Thumbnail` varchar(255) NOT NULL, `BigImage` varchar(255) NOT NULL, `Price` float(8,2) unsigned NOT NULL, `RetailPrice` float(8,2) unsigned NOT NULL, `Category` varchar(50) NOT NULL, `Subcategory` varchar(50) NOT NULL, `Description` text NOT NULL, `Custom1` varchar(255) NOT NULL, `Custom2` varchar(255) NOT NULL, `Custom3` varchar(255) NOT NULL, `Custom4` varchar(255) NOT NULL, `Custom5` varchar(255) NOT NULL, `Lastupdated` datetime NOT NULL, `Status` varchar(50) NOT NULL, `Manufacturer` varchar(255) NOT NULL, `PartNumber` varchar(255) NOT NULL, `MerchantCategory` varchar(255) NOT NULL, `MerchantSubcategory` varchar(255) NOT NULL, `ShortDescription` varchar(255) NOT NULL, `ISBN` varchar(25) NOT NULL, `UPC` varchar(25) NOT NULL, `SKU` varchar(255) NOT NULL, `CrossSell` varchar(255) NOT NULL, `MerchantGroup` varchar(255) NOT NULL, `MerchantSubgroup` varchar(255) NOT NULL, `CompatibleWith` varchar(255) NOT NULL, `CompareTo` varchar(255) NOT NULL, `QuantityDiscount` varchar(255) NOT NULL, `Bestseller` tinyint(1) unsigned NOT NULL, `AddToCartURL` varchar(255) NOT NULL, `ReviewsRSSURL` varchar(255) NOT NULL, `Option1` varchar(255) NOT NULL, `Option2` varchar(255) NOT NULL, `Option3` varchar(255) NOT NULL, `Option4` varchar(255) NOT NULL, `Option5` varchar(255) NOT NULL, `bActiveProduct` tinyint(1) unsigned NOT NULL, UNIQUE KEY `ProductID` (`ProductID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
I’m wrapping up the script which loads the data, which will be posted tomorrow.
Turn Datafeeds Into Affiliate Store In 3 Easy Steps - No HTML Knowledge
Custom programmed datafeed sites can be a little too mcuh for some people. That's ok! That's why there's Datafeedr.
If you think building an affiliate store was just too hard, then Datafeedr's Click & Create
system is just what you've been waiting for. Even if you have no experience with web design at all, you can have your own datafeed-driven affiliate site up and running today. Watch the video NOW and see this Push-Button Store Creation System in action!





{ 2 comments… read them below or add one }
Thanks for all answer. I have two questions;
1- when you create the database, why don’t you put an ID autoincrement as the first element of the product table?
2- can you give me your opinion about sqlite as the database for datafeed website?
thanks!
1 – ProductID is unique, and given by the network. No need for another id
2 – Nope
I’ve never used sqlite, sorry
Eric
{ 1 trackback }