Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.