CREATE TABLE `cms_beta_keys` (
`id` int(11) NOT NULL AUTO_INCREMENT ,
`beta_key` varchar(25) NULL DEFAULT '' ,
PRIMARY KEY (`id`));
<?php
function filter($var)
{
return mysql_real_escape_string(stripslashes(htmlspecialchars($var)));
}
if (isset($_POST['submit'])) {
if (empty($_POST['beta_key'])) {
echo 'You didn\'t enter a BETA key!';
} else {
mysql_connect("localhost", "root", "password") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
if (mysql_num_rows(mysql_query("SELECT `beta_key` FROM `cms_beta_keys` WHERE `beta_key` = '".filter($_POST['beta_key'])."'")) == 0) {
echo 'That isn\'t a valid BETA key!';
} else {
echo 'Beta key is valid!';
//Do what you want here (set a session or cookie for their access to register
//mysql_query("DELTE FROM `cms_bet_keys` WHERE `beta_key` = '".filter($_POST['beta_ket'])."' LIMIT 1");
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Welcome - BETA Key.</title>
</head>
<body>
<form action="#" method="POST">
<input type="text" name="beta_key"><br/>
<input type="submit" name="submit" value="Submit!">
</form>
</body>
</html>
Here is something quick for you to work on, it is using the MySQL extension so make sure you're running a PHP installation before PHP 5.5.0.
PHP:CREATE TABLE `cms_beta_keys` ( `id` int(11) NOT NULL AUTO_INCREMENT , `beta_key` varchar(25) NULL DEFAULT '' , PRIMARY KEY (`id`));
PHP:<?php function filter($var) { return mysql_real_escape_string(stripslashes(htmlspecialchars($var))); } if (isset($_POST['submit'])) { if (empty($_POST['beta_key'])) { echo 'You didn\'t enter a BETA key!'; } else { mysql_connect("localhost", "root", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); if (mysql_num_rows(mysql_query("SELECT `beta_key` FROM `cms_beta_keys` WHERE `beta_key` = '".filter($_POST['beta_key'])."'")) == 0) { echo 'That isn\'t a valid BETA key!'; } else { echo 'Beta key is valid!'; //Do what you want here (set a session or cookie for their access to register //mysql_query("DELTE FROM `cms_bet_keys` WHERE `beta_key` = '".filter($_POST['beta_ket'])."' LIMIT 1"); } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Welcome - BETA Key.</title> </head> <body> <form action="#" method="POST"> <input type="text" name="beta_key"><br/> <input type="submit" name="submit" value="Submit!"> </form> </body> </html>
I can probably do something with this code, but i'm not looking to put it on the register :/ I was looking to let all users register, then add the beta key on the 'me.php' page. and if they try to access the client it gives them an error.
You should of said, lol. - What CMS?
function generate_key()
{
$character_set_array = array();
$character_set_array[] = array('count' => 4, 'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
$character_set_array[] = array('count' => 4, 'characters' => '0123456789');
$temp_array = array();
foreach ($character_set_array as $character_set) {
for ($i = 0; $i < $character_set['count']; $i++) {
$temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
}
}
shuffle($temp_array);
return implode('', $temp_array);
}
Then give your 'man'Edit of RealityCMS, Big edit by my man Lucas if you want i can get you tv dets via PM.