Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* Copyright 2011 Aaron Roderigues */
- function doesUsernameExist($name){
- $exit = FALSE;
- $result = @mssql_query("SELECT * FROM dbo.ACCOUNT_TBL WHERE account='$name'");
- if(mssql_num_rows($result) != 0){
- $exit = TRUE;
- }
- return $exit;
- }
- function cl($info){
- return strtolower(preg_replace("|[^\w]|", "", $info));
- }
- if(isset($_POST['submit'])){
- /* Start editing */
- $salt = "kikugalanet";
- $secure_email = $_POST['email'];
- $cash = 0;
- $link = @mssql_connect("PRiiME", "sa", "Hallo!123") or die ("Server is down!");
- $db = @mssql_select_db('ACCOUNT_DBF') or die ("Accout table is missing!");
- /* */
- $username = cl($_POST['username']);
- $password = cl($_POST['password']);
- $password_hashed = md5($salt.$password);
- if(empty($username) || strlen($username) > 15){
- echo "Problem with your username.";
- exit();
- }
- else if(empty($password) || strlen($password) > 36){
- echo "Problem with your password.";
- exit();
- }
- else if(doesUsernameExist($username)){
- echo "Username already exists.";
- exit();
- }
- /* Passed everything, so lets create the account. */
- $stmt = mssql_init('usp_CreateNewAccount', $link);
- mssql_bind($stmt, '@account', $username, SQLVARCHAR, false, false, 32);
- mssql_bind($stmt, '@pw', $password_hashed, SQLVARCHAR, false, false, 32);
- mssql_bind($stmt, '@cash', $cash, SQLINT1, false, false);
- mssql_bind($stmt, '@email', $secure_email, SQLVARCHAR, false, false, 100);
- mssql_execute($stmt) or die ("Something is wrong on the execution.");
- mssql_free_statement($stmt);
- echo "User account created for: ".$username;
- mssql_close($link);
- exit();
- }
- ?>
- <!DOCTYPE html>
- <html>
- <body>
- <div>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
- <table>
- <tr>
- <td>Username:</td>
- <td><input size="20" name="username" maxlength="15" type="text" /></td>
- <td>(A-Z, a-z, 1-9)</td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input size="20" name="password" maxlength="35" type="password" /></td>
- <td>(A-Z, a-z, 1-9)</td>
- </tr>
- <tr>
- <td>Email:</td>
- <td><input size="20" name="email" maxlength="255" type="text" /></td>
- </tr>
- </table>
- <input type="submit" name="submit" value="register" />
- </form>
- </div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment