Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- <?php
- if ($_POST)
- {
- require_once 'db.php';
- $username = mysql_real_escape_string(preg_replace('/[a-zA-Z0-9]/', '', $_POST['username'])); // Only allows alphanumeric characters for username
- $password = $_POST['password'];
- $confirm = $_POST['confirm'];
- if ($_POST['username'] !== $username) // Check username input
- {
- echo 'Your username must only contains alphanumeric characters';
- }
- elseif ($password !== $confirm) // Check password confirmation
- {
- echo 'Your password do not match';
- }
- else
- {
- $result = mysql_query('SELECT COUNT(id) AS found FROM users WHERE username = "'.$username.'"');
- if($result) // Username taken
- {
- echo 'Username is already taken';
- }
- else
- {
- $password .= '46jhdgj$^&#$^+_DF';
- $password = mysql_real_escape_string(sha1(strrev($password)));
- mysql_query('INSERT INTO users (id, username, password) VALUES ("", "'.$username.'", "'.$password.'")'); // Insert the registration data to the database... (id, username, password)
- echo 'Successfully registered!';
- }
- }
- }
- ?>
- <form name='register' method='post' action='register.php'>
- Username: <input type='text' name='username' /><br />
- Password: <input type='text' name='password' /><br />
- Confirm: <input type='text' name='confirm' /><br />
- <input type='submit' value='Submit' />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement