[R63 RP] Beta code

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?
 

JayC

Always Learning
Aug 8, 2013
5,494
1,398
its 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
}
}
?>
 

momintaysir

New Member
Mar 16, 2013
27
0
A
its 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
}
}
?>
Alright ive done that
But my client is still loading? It dosent say like were on beta please come back l8 or something
 

Vatican

King
May 26, 2015
113
13
If you're using the code Jay gave you, edit your table and implement the column named "betacode". After, simply make random betacodes and assign them to whichever users you choose.
 

JayC

Always Learning
Aug 8, 2013
5,494
1,398
Your client code is going to go in the
//do what you want here (remove the <?php and ?> at the start and end of the client.php file)
and then you need to put the form in php code
<?php
if(!isset($_POST['beta'])){
?>
<span><strong><center>Beta Code</strong></span>
<form method="post">
<input type="text" name="beta">
</form></center>

<?php
}
?>
 

Jaden

not so active
Aug 24, 2014
886
263
Heres my code, Runs with Regular RevCMS.
PHP:
<?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;
    }
}
?>
You can just hit me up for the HTML form, that's for your page where you enter your beta codes.
Also added a special feature which allows you to generate a new beta key if you're staff.
PHP:
<?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;
}
?>
For the pages restricted to BETA testers (Add to the very TOP of the page).
PHP:
<?php
if (isset($_messages['beta_success'])) {
    echo '<div clas="some-custom-css">'.$_messages['beta_success'].'</div>';
}
?>
And that's how the message system works...
Again, let me know if you need the HTML... Sorry for the messy code I was in a rush!
 
Last edited:

Users who are viewing this thread

Top