Advertisement
Guest User

Untitled

a guest
Oct 7th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. <?php
  2. session_start(); //allows session
  3. include "config.php";
  4. echo "<center>";
  5. if(isset($_GET['register'])) {
  6. //check to see if any fields were left blank
  7. if((!$_POST[username]) || (!$_POST[password]) || (!$_POST[cpassword]) || (!$_POST[email])) {
  8. echo "A field was left blank please go back and try again.";
  9. }else{
  10. //posts all the data from the register form
  11. $username = $_POST[username];
  12. $password = $_POST[password];
  13. $cpassword = $_POST[cpassword];
  14. $email = $_POST[email];
  15. //check see if the 2 passwords are the same
  16. $check=array(
  17. 1 => "Admin",
  18. 2 => "Administrator",
  19. 3 => "root",
  20. 4 => "System"
  21. );
  22. foreach($check as $c){
  23. if(strstr($username,$c)){
  24. $detected = "True";
  25. }
  26. }
  27. if($detected == 'True')
  28. {
  29. echo "Bad username detected, Please use a different username.";
  30. }
  31. else
  32. if($password == $cpassword)
  33. {
  34. //encrypts the password 8 times
  35. $password = sha1(md5(md5(sha1(md5(sha1(sha1(md5($password))))))));
  36. $cname = mysql_query("SELECT `username` FROM `members` WHERE `username` = '$username'");
  37. $cname= mysql_num_rows($cname);
  38. //checks to see if the username or email allready exist
  39. if($cname>=1) {
  40. echo "The username is already in use";
  41. }else{
  42. //gets rid of bad stuff from there username and email
  43. $username = addslashes(htmlspecialchars($username));
  44. $email = addslashes(htmlspecialchars($email));
  45.  
  46.  
  47. $adduser = mysql_query("INSERT INTO `members` (`username`, `password`, `email`, `userlevel`) VALUES('$username','$password','$email','2')");
  48. echo "You are now registered,<br><br>You can now loggin to your account";
  49. }
  50. }
  51. }else{
  52. echo "Your password and conformation password do not match!";
  53. }
  54. }
  55. }else{
  56. //none of the above so lets show the register form
  57. echo "<form action='register.php?register' method='post'>
  58. <table width='350'>
  59. <tr>
  60. <td width='150'>Chat Username:</td>
  61. <td width='200'><input type='text' name='username' size='30' maxlength='25'></td>
  62. </tr>
  63. <tr>
  64. <td>Password:</td>
  65. <td><input type='password' name='password' size='30' maxlength='25'></td>
  66. </tr>
  67. <tr>
  68. <td>Confirm Password:</td>
  69. <td><input type='password' name='cpassword' size='30' maxlength='25'></td>
  70. </tr>
  71. <tr>
  72. <td>Email:</td>
  73. <td><input type='text' name='email' size='30' maxlength='55'></td>
  74. </tr>
  75. <tr>
  76. <td colspan='2'><center><input type='submit' value='Register'></center></td>
  77. </tr>
  78. </table>
  79. </form>";
  80. }
  81. }
  82. echo "<center>";
  83. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement