Jump to content

How can I make this


ronnie1988

Recommended Posts

Hi I just wanted to know how I can make this....

 

I want to write this in PHP, I dont know the best way to do this....

 

I am starting a software development company, Each time someone make a purchase of a software product I wan to include a cd key, I dont know how to include just one cd key... I want to place the cdkeys in a mysql db though which I know how to do, but just the fact of me taking only one cdkey out of it and it can't be used already... it has to go down the line how would I do this?

 

Thanks ahead of time

Link to comment
https://forums.phpfreaks.com/topic/212040-how-can-i-make-this/
Share on other sites

CREATE TABLE cdKey (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
cd_keys VARCHAR(100) NOT NULL,
used_by VARCHAR(20) NOT NULL,
used INT(1) DEFAULT 0
);

 

$sql = "SELECT id,cd_key FROM cdKey WHERE used = 0 ORDER BY id DESC LIMIT 1";  
$result = mysql_query($sql); //Get the results of the query into a resource pool.
if(mysql_num_rows($result) > 0) { //if that resource contains data.
  $row = mysql_fetch_row($result); //pull that data from the resource pool.
  echo $row[1]; //the second index should hold the cd_key.
$user = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); //get the users ip address <- faulty at best.
  $sql = "UPDATE cdKey SET used=1, used_by='$user' WHERE id={$row[0]}"; //update the cd_key row to used, and inserts the users IP address.
mysql_query($sql); //execute the query.
}

 

 

Something along these lines should do it.  You really need to nail down how you want the system to interact with your software.  What data you want to collect from the user, and log to the cd_key.  If you want to assign a software code to the cd_key. ETC.

Link to comment
https://forums.phpfreaks.com/topic/212040-how-can-i-make-this/#findComment-1105042
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.