Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- I herd you liek php
- </title>
- </head>
- <body>
- <?php
- require('config.php')
- ?>
- <?php
- // Checks if user is logged in
- if(isset($_SESSION['loggedin']) == 1)
- {
- echo 'You are already logged in please go to the index';
- }
- //checls for the register button, if found executes the registery
- else if(isset($_POST['register']))
- {
- $username = strip_tags(mysql_real_escape_string($_POST['user']));
- $password = md5( strip_tags(mysql_real_escape_string($_POST['pass'])));
- $pass2 = md5(strip_tags(mysql_real_escape_string($_POST['password'])));
- $ip = $_SERVER['REMOTE_ADDR'];
- //checks if all forms were filled in.
- if (empty ($username)||empty($password)||empty($pass2))
- {
- echo ' Please make sure you have filled in both fields and try again';
- }
- //checks if pass1 and pass2 were filled in the same for security reasons.
- else if ($password !== $pass2)
- {
- echo 'Passwords dont match';
- }
- else
- {
- $usertaken = mysql_query ("SELECT * FROM users WHERE `username` = '$username'");
- if (mysql_num_rows ($usertaken) == 1)
- {
- echo 'This name has been taken';
- }
- else if (mysql_num_rows ($ip) == 3)
- {
- echo 'You already have the limit of 3 accounts.';
- }
- else
- {
- //sql query if all checks out.
- mysql_query("INSERT INTO `users` (`username`, `password`, `ip`) VALUES ('{$username}','{$password}','{$ip}')");
- }
- }
- }
- ?>
- <form action="index.php" method="post">
- <center>
- Username: <input type="textbox" name="user">
- <br />
- Password: <input type="password" name="pass">
- <br />
- Repeat Password: <input type="password" name="password">
- <br />
- <input type="submit" value="Register" name="register">
- </center>
- </form>
Add Comment
Please, Sign In to add comment