Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $mysql_host = "127.0.0.1";
- $mysql_user = "root";
- $mysql_pass = "pass";
- $mysql_db = "hii";
- $action = "";
- if (isset($_GET['action']))
- $action = $_GET["action"];
- ?>
- <?php
- function udb_hash($pass)
- {
- $length = strlen($pass);
- $s1 = 1;
- $s2 = 0;
- for($n = 0; $n < $length; $n++)
- {
- $s1 = ($s1 + $pass[$n]) % 65521;
- $s2 = ($s2 + $s1) % 65521;
- }
- $wy = ($s2 << 16) + $s1;
- return $wy;
- }
- ?>
- <h1>Register Placeholder</h1>
- <form name="register" action="register.php?action=doregister" method="post">
- <table>
- <tr>
- <td>SA-MP Name:</td>
- <td><input type="text" name="username" /></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type="password" name="password" />
- </tr>
- <tr>
- <td>Email:</td>
- <td><input type="text" name="email" />
- </tr>
- <tr>
- <td colspan="2">
- <center><input type="submit" value="Register" style="width: 200px;" /></center>
- </td>
- </tr>
- </table>
- </form>
- <?php
- if (strcmp($action, "doregister") == 0)
- {
- $con = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
- if (!$con)
- {
- die(mysql_error());
- }
- mysql_select_db($mysql_db, $con);
- $username = $_POST['username'];
- $password_raw = $_POST['password'];
- $password = udb_hash($password_raw);
- $email = $_POST['email'];
- $result = mysql_query("SELECT * FROM accounts WHERE username='$username'", $con);
- if (mysql_num_rows($result) != 0)
- {
- die("An account already exists with that username.");
- }
- if (strlen($username) > 24)
- {
- die("Username is too large.");
- }
- mysql_query("INSERT INTO accounts (username, password, email) VALUES ('$username', '$password', '$email')", $con);
- echo "Account created.";
- mysql_close($con);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement