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.
7 1439
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:
Thanks! Okay then, so that is the first step.
Now, i need to create a database that holds all of the pin numbers. How?
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 - CREATE TABLE references (id INT PRIMARY KEY AUTO_INCREMENT,
-
date_time TIMESTAMP,
-
reference_code VARCHAR(40),
-
product_id VARCHAR(10))
Then your (very crude) HL design would look like: -
If order is submitted:
-
- obtain product_id of ordered item
-
- generate reference_code
-
- store reference_code, date_time and product_id in table 'references'
-
- create email (with reference_id in link)
-
- send email
-
When user places order:
-
- get reference_id from url
-
- read reference_id and product_id from table 'references'
-
- if not valid reference_id: issue error message and exit
-
- if valid reference:
-
- prepare product download
-
- download product
-
- clear entry from table 'references'
-
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:
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 - CREATE TABLE references (id INT PRIMARY KEY AUTO_INCREMENT,
-
date_time TIMESTAMP,
-
reference_code VARCHAR(40),
-
product_id VARCHAR(10))
Then your (very crude) HL design would look like: -
If order is submitted:
-
- obtain product_id of ordered item
-
- generate reference_code
-
- store reference_code, date_time and product_id in table 'references'
-
- create email (with reference_id in link)
-
- send email
-
When user places order:
-
- get reference_id from url
-
- read reference_id and product_id from table 'references'
-
- if not valid reference_id: issue error message and exit
-
- if valid reference:
-
- prepare product download
-
- download product
-
- clear entry from table 'references'
-
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?
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:
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?
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:
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
by: CLEAR-RCIC |
last post by:
Where can I find the serial number that I need for installing Windows XP from
MSDN?
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |