473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Pin Number Downloads - How?

Hello,

Firstly, i would just like to say this is my first time on this site, and it looks rather cool and helpful!

Now, i need a script that:

[HTML]-When the customer purchases a product, a random pin number is given to them automatically by E-MAIL (which they insert in the shop form).

-Then, when they go on to the product page, they insert the pin number - Checks to see if the pin is valid, and what product it belongs to.

-The protected download file starts downloading.

-The pin number is then deleted out of the database/data file.[/HTML]

I have never used PHP before, so can somebody help me out here?

Thanks,
Jake.
Oct 8 '06 #1
7 1439
ronverdonk
4,258 Expert 4TB
The following sample is from the php.net documentation's PHP Rand function
[PHP]<?php

function randomkeys($length)
{
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
for($i=0;$i<$length;$i++)
{
$key .= $pattern{rand(0,35)};
}
return $key;
}

echo randomkeys(8),"<br>";
echo randomkeys(16),"<br>";
echo randomkeys(32),"<br>";
echo randomkeys(64),"<br>";

?>

output:

n94bv1h7
y9qi1qu2us3wged2
00dhax4x68028q96yyoypizjb2frgttp
478d4ab0ikapaiv0hk9838qd076q1yf46nh0ysigds6ob2xtl6 1odq2nx8dx7t2b
[/PHP]

Ronald :cool:
Oct 9 '06 #2
Thanks! Okay then, so that is the first step.

Now, i need to create a database that holds all of the pin numbers. How?
Oct 9 '06 #3
ronverdonk
4,258 Expert 4TB
I don't think it is a good iedea to create a table with reserved numbers. Instead it is better to create the number dynamically when the order is placed and you heberate the email.
You would have to, to start with, create a table named 'references' such as
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE references (id INT PRIMARY KEY AUTO_INCREMENT,
  2. date_time TIMESTAMP,
  3. reference_code VARCHAR(40), 
  4. product_id VARCHAR(10))
Then your (very crude) HL design would look like:
Expand|Select|Wrap|Line Numbers
  1. If order is submitted:
  2. -  obtain product_id of ordered item
  3. -  generate reference_code
  4. -  store reference_code, date_time and product_id in table 'references'
  5. -  create email (with reference_id in link)
  6. -  send email
  7. When user places order:
  8. -  get reference_id from url
  9. -  read reference_id and product_id from table 'references'
  10. -  if not valid reference_id: issue error message and exit
  11. -  if valid reference:
  12.    - prepare product download
  13.    - download product
  14.    - clear entry from table 'references'
  15.  
Be aware that this forum is to help you, not to write code for you. You have to do that yourself. So, in case you have to brush-up your programming skills, do so before you go on with this. Good luck!

Ronald :cool:
Oct 9 '06 #4
I don't think it is a good iedea to create a table with reserved numbers. Instead it is better to create the number dynamically when the order is placed and you heberate the email.
You would have to, to start with, create a table named 'references' such as
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE references (id INT PRIMARY KEY AUTO_INCREMENT,
  2. date_time TIMESTAMP,
  3. reference_code VARCHAR(40), 
  4. product_id VARCHAR(10))
Then your (very crude) HL design would look like:
Expand|Select|Wrap|Line Numbers
  1. If order is submitted:
  2. -  obtain product_id of ordered item
  3. -  generate reference_code
  4. -  store reference_code, date_time and product_id in table 'references'
  5. -  create email (with reference_id in link)
  6. -  send email
  7. When user places order:
  8. -  get reference_id from url
  9. -  read reference_id and product_id from table 'references'
  10. -  if not valid reference_id: issue error message and exit
  11. -  if valid reference:
  12.    - prepare product download
  13.    - download product
  14.    - clear entry from table 'references'
  15.  
Be aware that this forum is to help you, not to write code for you. You have to do that yourself. So, in case you have to brush-up your programming skills, do so before you go on with this. Good luck!

Ronald :cool:
Okay, thanks for the help.

Just one thing, would the reference_code be a database or a file? And where would the table 'reference' be?
Oct 9 '06 #5
ronverdonk
4,258 Expert 4TB
I think you have something to learn first about MySQL.

You do a create of a table (here 'references') after having selected the database
[php]mysql_select_db("db_name");[/php]
reference_code here is neither a database nor a file. It is a column in table 'references' that was created in the example. Into what database this tabe is created depends on the preceeding db selection.

As I said, you'd better do some tutorials on MySQL before you continue. Some of these are:

PHP MySQL tutorial
PHP FOR THE ABSOLUTE BEGINNER

Ronald :cool:
Oct 9 '06 #6
I would like to say, that i don't host the server. I bought a web domain with hosting from www.spacialhosting.com, so how can i use DOS to make databases and such?
Oct 10 '06 #7
ronverdonk
4,258 Expert 4TB
Look at the contract or the guidelines from your server provider. It will say something about usage of the database (its name(s), how to connect, what you are allowed to do and not, etc.) and about using a MySQL administrative user interface such as phpAdmin or the like.

Ronald :cool:
Oct 10 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bart Plessers \(artabel\) | last post by:
Hello, I have an asp script that lists the files in a directory: CurrentPATH = "c:\temp\" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(CurrentPATH) Set...
4
by: William Morris | last post by:
Our application tracks contact information. One of our clients, a car dealership, has asked about being able to enter a lastname and phone number and getting as much of the main form filled out as...
9
by: martin | last post by:
Hi, a very newbie question. How do I split the adress and number to 2 variables? ex. "Kingsroad 347" = variabel1 = "Kingsroad" variabel2 = "347" Ill guess i have to search the string from...
6
by: John Bentley | last post by:
John Bentley writes at this level: If we think about our savings accounts then division never comes in (as far as I can see). We deposit and withdraw exact amounts most of the time. Occasionaly...
1
by: CLEAR-RCIC | last post by:
Where can I find the serial number that I need for installing Windows XP from MSDN?
2
by: johnivey | last post by:
I have a large query that I am trying to debug in query analyzer. However, the errors I get have no line number or reference to where they are failing. How can I find out what line in the query is...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
32
by: Nu | last post by:
I want to protect myself from if someone with a fast connection hammers my site. It's not denial of service attacks, but offline downloaders (of course that don't show they're offline downloaders...
1
by: GaryDean | last post by:
I now have installed (from the same install) Enterprise Library - January 2006 and Enterprise Library - June 2005. The install for these two was called Enterprise Library for .Net 2.0. (not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.