Register page

Socius Decennalis
Decennium
Joined
Apr 8, 2009
Messages
60
Reaction score
8
Hi all,

I've made a simple register page for the official server files:
PHP:
<?php
ini_set('display_errors', 0); 
$connection = mssql_connect('YOURHOST', 'sa', 'YOURPASSWORD'); //Change YOURHOST and YOURPASSWORD

if(!connection || !mssql_select_db('ACCOUNT_DBF', $connection)) 
{
    die('Unable to connect or select database!');
}

$checkusername = $_POST['Username'];
$query = mssql_query("SELECT account FROM ACCOUNT_TBL WHERE account = '$checkusername'");
$result = mssql_fetch_row($query);

if(isset($_POST['submit'])){
	if($_POST['Username'] == ""){
		$error = '<font color="red">Please enter a username.</font>';
	}
	else if($result[0] == $checkusername){
		$error = '<font color="red">This username already exists. Please choose another one.</font>';
	}
	else if($_POST['Password'] == ""){
		$error = '<font color="red">Please enter a password.</font>';
	}
	else if($_POST['Password2'] == ""){
		$error = '<font color="red">You did not repeat your password.</font>';
	}
	else if($_POST['Password'] != $_POST['Password2']){
		$error = '<font color="red">Passwords do not match.</font>';
	}
	else if($_POST['birthday'] == ""){
		$error = '<font color="red">Please enter your birthday.</font>';
	}
	else if($_POST['mail'] == ""){
		$error = '<font color="red">Please enter your e-mail adress.</font>';
	}
	else{
		$password = md5('nForceIsGay' . $_POST['Password']);
		$stmt = mssql_init('webCreateAcc', $connection);
                mssql_bind($stmt, '@account', $checkusername, SQLVARCHAR, false, false, 15);
                mssql_bind($stmt, '@password', $password, SQLVARCHAR, false, false, 36);
                mssql_bind($stmt, '@birthday', $_POST['birthday'], SQLVARCHAR, false, false, 120);
                mssql_bind($stmt, '@email', $_POST['mail'], SQLVARCHAR, false, false, 120);
                mssql_execute($stmt) or die ("Could not complete the registration. Please try again.");
                mssql_free_statement($stmt);
				$error = '<font color="green">Registration complete!</font>';
	}
}

echo '<form action="register.php" method="post">';
echo 'Username:            <input type="text" name="Username" /><br /><br />';
echo 'Password:            <input type="password" name="Password" /><br /><br />';
echo 'Repeat password: <input type="password" name="Password2" /><br /><br />';
echo 'Birthday:              <input type="text" name="birthday" /><br /><br />';
echo 'E-mail:                  <input type="text" name="mail" /><br />';
echo '<input type="submit" name="submit" value="Register" />';
echo '</form>';
echo $error;

?>

How to use:
#1: Change the host and the password at the beginning of this code.
#2: Save this code as register.php.
#3: Enjoy!

Credits:
Credits go to me and zyberscape (For using a small piece of his code).
 
Last edited:
its not doing is a white screen
PHP:
   <?php
ini_set('display_errors', 0); 
$connection = mssql_connect('Ghetto-PC\SQLEXPRESS', 'sa', '1234567'); //Change YOURHOST and YOURPASSWORD

if(!connection || !mssql_select_db('ACCOUNT_DBF', $connection)) 
{
    die('Unable to connect or select database!');
}

$checkusername = $_POST['Username'];
$query = mssql_query("SELECT account FROM ACCOUNT_TBL WHERE account = '$checkusername'");
$result = mssql_fetch_row($query);

if(isset($_POST['submit'])){
    if($_POST['Username'] == ""){
        $error = '<font color="red">Please enter a username.</font>';
    }
    else if($result[0] == $checkusername){
        $error = '<font color="red">This username already exists. Please choose another one.</font>';
    }
    else if($_POST['Password'] == ""){
        $error = '<font color="red">Please enter a password.</font>';
    }
    else if($_POST['Password2'] == ""){
        $error = '<font color="red">You did not repeat your password.</font>';
    }
    else if($_POST['Password'] != $_POST['Password2']){
        $error = '<font color="red">Passwords do not match.</font>';
    }
    else if($_POST['birthday'] == ""){
        $error = '<font color="red">Please enter your birthday.</font>';
    }
    else if($_POST['mail'] == ""){
        $error = '<font color="red">Please enter your e-mail adress.</font>';
    }
    else{
        $password = md5('nForceIsGay' . $_POST['Password']);
        $stmt = mssql_init('webCreateAcc', $connection);
                mssql_bind($stmt, '@account', $checkusername, SQLVARCHAR, false, false, 15);
                mssql_bind($stmt, '@password', $password, SQLVARCHAR, false, false, 36);
                mssql_bind($stmt, '@birthday', $_POST['birthday'], SQLVARCHAR, false, false, 120);
                mssql_bind($stmt, '@email', $_POST['mail'], SQLVARCHAR, false, false, 120);
                mssql_execute($stmt) or die ("Could not complete the registration. Please try again.");
                mssql_free_statement($stmt);
                $error = '<font color="green">Registration complete!</font>';
    }
}

echo '<form action="register.php" method="post">';
echo 'Username:            <input type="text" name="Username" /><br /><br />';
echo 'Password:            <input type="password" name="Password" /><br /><br />';
echo 'Repeat password: <input type="password" name="Password2" /><br /><br />';
echo 'Birthday:              <input type="text" name="birthday" /><br /><br />';
echo 'E-mail:                  <input type="text" name="mail" /><br />';
echo '<input type="submit" name="submit" value="Register" />';
echo '</form>';
echo $error;

?>
 
as with all other register pages that are released it appears to have no sanitisation, if anyone plans on using it it would need a little and i do only mean a little work to add an anti sql injection function
 
as with all other register pages that are released it appears to have no sanitisation, if anyone plans on using it it would need a little and i do only mean a little work to add an anti sql injection function

Someone released a good one. He put so many errors in it though >> everything was sanitized except for $_POST['email']. Nice people.
 
Thanks, this is perfect for non-public servers when you just want to make your own accounts. Is there any way you can make it so when you make an account, it makes you a GM? I don't think so, since the Authority is in the Character_Dbf and that's only after you make a char, but just making sure.

Possibly a way to change the Authority when an character is created? [not an account]
 
Thanks, this is perfect for non-public servers when you just want to make your own accounts. Is there any way you can make it so when you make an account, it makes you a GM? I don't think so, since the Authority is in the Character_Dbf and that's only after you make a char, but just making sure.

Possibly a way to change the Authority when an character is created? [not an account]

If you know mssql you can create a field at account table that tells it authority and change the create char procedure to mirror that value. But please, dont create topics asking for someone to do this for you(you as in anyone reading this post, not just coryyy).
 
Thanks, this is perfect for non-public servers when you just want to make your own accounts. Is there any way you can make it so when you make an account, it makes you a GM? I don't think so, since the Authority is in the Character_Dbf and that's only after you make a char, but just making sure.

Possibly a way to change the Authority when an character is created? [not an account]

There is another webpage code to make your self a gm.
any way idk how to use this any help im noob and will read alot to learn.:thumbup:
 
1. Download and install Xampp (look it up on google)
2. Enable mssql in php.ini
3. Save this script in your htdocs folder
4. Enjoy :D
 
Back