Creating a E-commerce database?

Hey guys, I’ve recently been looking into creating an E-commerce shop where I can sell items online, however I am unsure exactly what I need to look into in order for this to happen. I don’t mind learning how to create all this if required, or if there are templates out there I should be using, I really have no idea at this point. Basically, my goal is to not sell hard goods like T-shirts, but instead files, similar to a stock photo site.

So really, my question is, how would I go about creating an online store that would send the buyer the “picture” once purchased?

I believe this is to do with a database, but if not, please let me know :stuck_out_tongue:



Edit: I’d like to add, I did look into paypal and found one they offer called “Cashie” @…basically all payments are done through paypal using their system. They only take 1% of your monthly income I believe. Is this along the lines of what I need?

Hmm, without trying to sound too rude it sounds like you don’t have a great understanding of web technologies.

This would normally be accomplished by having files stored on your server. You would have a database table that references these files (such as the name of the file in the file system, the title of the download, the cost, and any other information you wanted to store).

A user would then buy the download; this would be handled by a payment gateway such as PayPal. When a user “buys” an item, you can have PayPal send information to a URL on your server; this URL can be a script that creates an order in another table in your database (such as the customer’s details, purchase information, date, time, IP address). This same script can then also send the customer a download link via email.

There are numerous ways you can go about the actual download. Normally there would be a URL where the customer can download the file, and a key passed as part of the URL, i.e. IANA — Example domains. This key could then relate to a database record that returns the file name, whether this file has already been downloaded or not, and whether the download has expired or not. This would then send a header to force the download of the file if valid, or display an error message if not. Something like this:


// create database connection here

// fetch the orders details from the database
$key = $_GET['key'];
$res = mysql_query('SELECT * FROM orders WHERE key = ' . mysql_real_escape_string($key));
$row = mysql_fetch_assoc($res);

$downloads_dir = '/path/to/downloads/dir/';

if (is_array($row) && file_exists($downloads_dir . $row['filename'])) {
    header("Cache-Control: public");
    header("Content-Description: File Transfer");
    header("Content-Disposition: attachment; filename=" . $downloads_dir . $row['filename']);
    header("Content-Type: application/zip");
    header("Content-Transfer-Encoding: binary");
    readfile($downloads_dir . $row['filename']);
else {
    header('HTTP/1.1 500 Internal Server Error');
    echo '<p>An error occurred. Please try again later, or contact support.</p>';

Let me know if you want anything else clearing up.

Ah thanks for clearing that up, and yes, you guessed correctly, hehe. My strong side is more the design element of websites, not the coding / programming (Other than basic html / css). I’m trying to expand that knowledge and you definitely helped :wink:


No problem. The above just touched on all the different elements you would need to develop such a system, so if you need anything clearing up or explained in further detail, do let me know and I’ll try my best.