ronnie1988 Posted August 30, 2010 Share Posted August 30, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/212040-how-can-i-make-this/ Share on other sites More sharing options...
jcbones Posted August 30, 2010 Share Posted August 30, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/212040-how-can-i-make-this/#findComment-1105042 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.