momintaysir
New Member
- Mar 16, 2013
- 27
- 0
Hello guys i need a beta system , for like when i type beta code i can acces the client. But if i dont have beta code i cant. Someone give me the html code pls?
Alright ive done thatits going to be PHP code and this is really easy...
HTML:
<span><strong><center>Beta Code</strong></span>
<form method="post">
<input type="text" name="beta">
</form></center>
PHP:
<?php
if(isset($_POST['beta'])){
$checkcode = mysql_fetch_assoc(mysql_query("SELECT betacode from users WHERE username='".$_SESSION['user']['username']."' LIMIT 1"));
$enteredcode = $_POST['beta'];
if($enteredcode == $checkcode){
//Do what you want here
}
}
?>
<?php
$_messages = [];
function generateBetaKey($k = 0) {
global $engine;
if ($k == 0) {
$k = rand(1000, 9999);
$engine->query("INSERT INTO `beta_keys` (key, used) VALUES('".$k."', '0');");
$_messages['beta_success'] = 'Successfully generated a random beta key ('.$k.').';
return;
}
$engine->query("INSERT INTO `beta_keys` (key, used) VALUES('".$k."', '0');");
$messages['beta_success'] = 'Successfully generated the beta key ('.$k.').';
return;
}
function checkBetaKey($key) {
global $engine;
if ($engine->num_rows("SELECT null FROM `beta_keys` WHERE `key` = '".$key."' AND `used` = '0' LIMIT 1;") > 0) {
return true;
}
return false;
}
if (isset($_POST['beta_submit'])) {
if (isset($_POST['beta_key'])) {
$k = $_POST['beta_key'];
if ($k < 4) {
$_messages['submit-error'] = 'Your beta key must be atleast 4 numbers!';
return;
}
else {
if (checkBetaKey($k)) {
$engine->query("UPDATE `users` SET `beta` = '1' WHERE `id` = '".$_SESSION['user_id']."' LIMIT 1;");
$engine->query("UPDATE `beta_keys` SET `used` = '1' WHERE `key` = '".$k."' LIMIT 1;");
$_messages['beta_success'] = "You've successfully registered as a BETA user.";
return;
}
else {
$_messages['submit-error'] = "You've entered an invalid beta key!";
return;
}
}
}
else if (isset($_POST['beta_create'])) {
$k = $_POST['beta_key'];
if ($k < 4) {
$_messages['submit-error'] = 'Your beta key must be atleast 4 numbers!';
return;
}
else {
generateBetaKey($k);
return;
}
}
else {
$_messages['submit-error'] = 'Please enter a valid key!';
return;
}
}
?>
<?php
global $engine;
if ($engine->num_rows("SELECT null FROM `users` WHERE `beta` = '1' AND `id` = '".$_SESSION['user_id']."' LIMIT 1;") <= 0) {
echo("You don't have beta access.");
exit;
}
?>
<?php
if (isset($_messages['beta_success'])) {
echo '<div clas="some-custom-css">'.$_messages['beta_success'].'</div>';
}
?>