Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start(); //allows session
- include "config.php";
- echo "<center>";
- if(isset($_GET['register'])) {
- //check to see if any fields were left blank
- if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])) {
- echo "A field was left blank please go back and try again.";
- }else{
- //posts all the data from the register form
- $username = $_POST[username];
- $password = $_POST[password];
- $cpassword = $_POST[cpassword];
- $email = $_POST[email];
- //check see if the 2 passwords are the same
- $check=array(
- 1 => "Admin",
- 2 => "Administrator",
- 3 => "root",
- 4 => "System"
- );
- foreach($check as $c){
- if(strstr($username,$c)){
- $detected = "True";
- }
- }
- if($detected == 'True')
- {
- echo "Bad username detected, Please use a different username.";
- }
- else
- if($password == $cpassword)
- {
- //encrypts the password 8 times
- $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($password))))))));
- $cname = mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'");
- $cname= mysql_num_rows($cname);
- //checks to see if the username or email allready exist
- if($cname>=1) {
- echo "The username is already in use";
- }else{
- //gets rid of bad stuff from there username and email
- $username = addslashes(htmlspecialchars($username));
- $email = addslashes(htmlspecialchars($email));
- $adduser = mysql_query("INSERT INTO `members` (`username`, `password`, `email`, `userlevel`) VALUES('$username','$password','$email','2')");
- echo "You are now registered,<br><br>You can now loggin to your account";
- }
- }
- }else{
- echo "Your password and conformation password do not match!";
- }
- }
- }else{
- //none of the above so lets show the register form
- echo "<form action='register.php?register' method='post'>
- <table width='350'>
- <tr>
- <td width='150'>Chat Username:</td>
- <td width='200'><input type='text' name='username' size='30' maxlength='25'></td>
- </tr>
- <tr>
- <td>Password:</td>
- <td><input type='password' name='password' size='30' maxlength='25'></td>
- </tr>
- <tr>
- <td>Confirm Password:</td>
- <td><input type='password' name='cpassword' size='30' maxlength='25'></td>
- </tr>
- <tr>
- <td>Email:</td>
- <td><input type='text' name='email' size='30' maxlength='55'></td>
- </tr>
- <tr>
- <td colspan='2'><center><input type='submit' value='Register'></center></td>
- </tr>
- </table>
- </form>";
- }
- }
- echo "<center>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement