Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Website] Register Script + Check User Function Added!

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jun 17, 2010
Messages
30
Reaction score
14
Hello, this is my first post so please be nice and no flaming. :D
If you don't want to make files below, you can download the files here.

Download :

Virus Scan (For people who think this is a virus) :

Antivir: Nothing found
ArcaVir: Nothing found
AVG: Nothing found
BitDefender: Nothing found
VirusBlokAda32: Nothing found
VirusBuster: Nothing found


Scanned by


Make a config.php file and put this in.
PHP:
<?php
// Mysql Info:
$host = 'localhost'; // The host: usually localhost.
$dbuser = 'root'; // The username used to connect to MySQL.
$dbpass = ''; // The password used in conjunction with the username.
$dbname = 'odinms'; // The name of the database containing OdinMS (or any pServer with the same accounts table)
mysql_connect($host, $dbuser, $dbpass) or die(mysql_errno().mysql_error());
mysql_select_db($dbname) or die(mysql_errno().mysql_error());
$disallowednames = array(
'admin', 'gamemaster', 'supergm'
); // Has to be atleast one value otherwise it won't work. Simply seperate each value with a comma. This is case sensitive, so I'd use as little values as possible.

?>

Make register.php and put this in.
PHP:
<head>
<script type="text/javascript" language="javascript" src="javascript.js"> </script><!-- Feel free to remove this, if you want it to stop working. --></head>
<!-- Don't remove any divs or ids! -->
<div id="form">
<form method="post" action="register_process.php?njx=true">
Username: <input type="text" name="name" id="name" maxlength="13"><div id="check"><input type="button" onclick="checkname()" value="Check"></div> <div id="checkresponse"></div><br>
Password: <input type="password" name="pass" id="pass" maxlength="35"><br>
Verify Password: <input type="password" name="pass2" id="pass2" maxlength="35"><br>
Email: <input type="text" name="email" id="email" maxlength="50"><br>
D.O.B. (YYYY-MM-DD): <input type="text" name="dob" id="dob" maxlength="16"><br>
<div id="submit"><input type="button" value="Register!" onclick="register()"></div></form></div>

Make register_process.php and put this in.
PHP:
<?php if (isset($_REQUEST['njx'])) { ?>
<!-- The layout goes here -->
<!-- The space for the registration output - DONT GO INTO THE PHP! -->
<?php
    include ('config.php');

    $name = mysql_real_escape_string($_REQUEST['name']);
    $pass = mysql_real_escape_string(sha1($_REQUEST['pass']));
    $email = mysql_real_escape_string($_REQUEST['email']);
    $dob = mysql_real_escape_string($_REQUEST['dob']);
    $pass2 = mysql_real_escape_string(sha1($_REQUEST['pass2']));
    $query = mysql_query("SELECT 'id' FROM accounts WHERE name='$name'");
    if (empty($_REQUEST['name'])) {
        echo 'There was no username filled in.';
        die();

    } elseif (in_array($_REQUEST['name'], $disallowednames)) {
        echo 'Your name has been disallowed by the admin.';
        die();
    } elseif (!isset($_POST['userexists'])) {
        if (mysql_num_rows($query) > 0) {
            echo 'The selected user already exists.';
            die();
        }

    } elseif ($pass == "") {
        echo 'There was no password filled in.';
        die();

    } elseif ($_REQUEST['pass'] != $_REQUEST['pass2']) {
        echo 'The passwords did not match.';
        die();

    } elseif ($email == "") {
        echo 'There was no email filled in.';
        die();

    } elseif ($dob == "") {
        echo 'There was no Date Of Birth filled in.';
        die();
    }
    mysql_query("INSERT INTO accounts (name, password, email, birthday) VALUES('$name', '$pass', '$email', '$dob')") or
        die('Error #' . mysql_errno() . ': ' . mysql_error());
    echo 'Your account has been created, you can now login!';
?>
<!-- End registration output -->
<!-- Stop the layout! The rest of this is for the non-handicapped browsers! -->
<?php } else {
     include ('config.php');

    $name = mysql_real_escape_string($_REQUEST['name']);
    $pass = mysql_real_escape_string(sha1($_REQUEST['pass']));
    $email = mysql_real_escape_string($_REQUEST['email']);
    $dob = mysql_real_escape_string($_REQUEST['dob']);
    $pass2 = mysql_real_escape_string(sha1($_REQUEST['pass2']));
    $query = mysql_query("SELECT 'id' FROM accounts WHERE name='$name'");
    if (empty($_REQUEST['name'])) {
        echo 'There was no username filled in.';
        die();

    } elseif (in_array($_REQUEST['name'], $disallowednames)) {
        echo 'Your name has been disallowed by the admin.';
        die();
    } elseif (!isset($_POST['userexists'])) {
        if (mysql_num_rows($query) > 0) {
            echo 'The selected user already exists.';
            die();
        }

    } elseif ($pass == "") {
        echo 'There was no password filled in.';
        die();

    } elseif ($_REQUEST['pass'] != $_REQUEST['pass2']) {
        echo 'The passwords did not match.';
        die();

    } elseif ($email == "") {
        echo 'There was no email filled in.';
        die();

    } elseif ($dob == "") {
        echo 'There was no Date Of Birth filled in.';
        die();
    }
    mysql_query("INSERT INTO accounts (name, password, email, birthday) VALUES('$name', '$pass', '$email', '$dob')") or
        die('Error #' . mysql_errno() . ': ' . mysql_error());
    echo 'Your account has been created, you can now login!';
} ?>

Make checkuser.php and put this in.
PHP:
<?php
include ('config.php');
if (!isset($_REQUEST['name'])) {
    echo 'You didn\'t enter the name';
    die();
}
elseif (in_array($_REQUEST['name'], $disallowednames, true)) {
        echo '<font style="color: red;">Your name has been disallowed by the admin.</font>';
        die();
    }
$name = mysql_real_escape_string($_REQUEST['name']);
$query = mysql_query("SELECT 'id' FROM accounts WHERE name='$name'");
if (mysql_num_rows($query) > 0) {
    echo '<font style="color: red">The selected user exists</font><input type="hidden" name="userexists" value="1/' .
        $_REQUEST['name'] . '" id="verified">';
    exit();
} else {
    echo '<font style="color: green">The user doesn\'t exist!</font><input type="hidden" name="userexists" value="0/' .
        $_REQUEST['name'] . '" id="verified">';
}
?>

Make javascript.js and put this in.
PHP:
// Coded by SSJ5Goku. Thanks to DragoNero (Tizag) for looking over this :).
  function createResponse(){
        try {
          request = new XMLHttpRequest();//Geko
        } catch (trymicrosoft) {
          try {
            request = new ActiveXObject('Msxml2.XMLHTTP');//MS 1
          } catch (othermicrosoft) {
            try {
              request = new ActiveXObject('Microsoft.XMLHTTP');//MS 2
            } catch (failed) {
            }
          }
        }
        if (request == null){
alert("AJAX Doesn't work! Falling back to HTML...");
        	dooument.getElementById("check").innerHTML = ' ';
        	document.getElementById("submit").innerHTML = '<input type="submit" value="Register!">';
		}
  }

function checkname(){
  createResponse();
  var name = document.getElementById("name").value;
	var url = 'checkuser.php?dummy=' + new Date().getTime() + '&name=' + escape(name);
			request.open("GET", url, true);
			request.onreadystatechange = updatePage;
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			var name = document.getElementById("name").value;
			request.send(null);
}
function register(){
  createResponse();
	var url = 'register_process.php';
			var dob = document.getElementById("dob").value;
			var name = document.getElementById("name").value;
			var pass = document.getElementById("pass").value;
			var pass2 = document.getElementById("pass2").value;
			var email = document.getElementById("email").value;
			var sent = "name=" + escape(name) + "&pass=" + escape(pass) + "&pass2=" + escape(pass2) + "&email=" + escape(email) + "&dob=" + escape(dob);
			request.open("POST", url, true);
			request.onreadystatechange = updateForm;
			request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			request.send(sent);
}
function updatePage(){
	if(request.readyState == 4){
		if(request.status == 200){
	document.getElementById("checkresponse").innerHTML = request.responseText;
	}else{
		var message = request.getResponseHeader("Status");
		if((message.length == null) || (message.length <= 0)){
		alert("Error! The status of the request is " + request.status);
	}else{
		alert(message);
	}
	}
}
}
function updateForm(){
	if(request.readyState == 4){
		if(request.status == 200){
	document.getElementById("form").innerHTML = request.responseText;
	}else{
		var message = request.getResponseHeader("Status");
		if((message.length == null) || (message.length <= 0)){
		alert("Error! The status of the request is " + request.status);
	}else{
		alert(message);
	}
	}
}
}

Screenshot (Credits to billybombill):
xBlessingx - [Website] Register Script + Check User Function Added! - RaGEZONE Forums
 
Last edited:
Junior Spellweaver
Joined
Jan 29, 2009
Messages
187
Reaction score
2
Re: Register Script + Check User Function Added!

Nice job, anyone mind posting an SS?
 
Newbie Spellweaver
Joined
Jun 17, 2010
Messages
30
Reaction score
14
Re: Register Script + Check User Function Added!

I would, but I can't because I deleted MySQL, wampserver, etc.
It will be a hassle again to download and install all of them again.
Sorry.
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Re: Register Script + Check User Function Added!

Screenshot
xBlessingx - [Website] Register Script + Check User Function Added! - RaGEZONE Forums

Although the looks could be improved the script is nice, good thinking with the disallowed names too
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Re: Register Script + Check User Function Added!

No problem xD I would center it, add a fieldset around it, and add a bit of graphics
 
Experienced Elementalist
Joined
Nov 11, 2007
Messages
208
Reaction score
18
Re: Register Script + Check User Function Added!

Really Simple, But still great. I wish it wasn't that click thing, just type in your username and then it automatically checks for you :/
Anyways good work :)
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Re: Register Script + Check User Function Added!

You could do it with Ajax i suppose
 
Newbie Spellweaver
Joined
Jun 16, 2010
Messages
6
Reaction score
1
Re: Register Script + Check User Function Added!

get the one like localms.
automatically checks as you type in your username.
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Re: Register Script + Check User Function Added!

Added to library.
Nice release, i might use some parts for my cms ;)
 
Mother effin' clouds
Loyal Member
Joined
Apr 13, 2008
Messages
1,534
Reaction score
448
Re: Register Script + Check User Function Added!

Really Simple, But still great. I wish it wasn't that click thing, just type in your username and then it automatically checks for you :/
Anyways good work :)

Easy. Add a KeyUp or KeyDown event that would call the Username Check function.
 
Newbie Spellweaver
Joined
Jun 17, 2010
Messages
30
Reaction score
14
Re: Register Script + Check User Function Added!

In some sites, when you register and if it says, "Username already exists" you would have to type all your information again.
But with checkuser fuction, you can see if your username is available before registering.
 
Status
Not open for further replies.
Back
Top