Advertisement
Guest User

Untitled

a guest
Jul 27th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.24 KB | None | 0 0
  1. <?php
  2. /*-----------------------------------------------------------------------*/
  3. /*           Heinrich's News registration script  V0.01 ALPHA            */
  4. /*-----------------------------------------------------------------------*/
  5. $username = $_POST["username"];
  6. // connect (*IP, User, Password
  7. $con = mysql_connect("localhost","root","");
  8. //open database
  9. mysql_select_db("school", $con);
  10. /*----------------------*/
  11. /* PASSWORDS MD5 HASHED */
  12. /*----------------------*/
  13.  
  14. $password = $_POST["password"];
  15. $rpassword = $_POST["rpassword"];
  16. $date = date("Y/m/d");
  17. /* DYNAMIC USER ID INSERT TO DB */
  18.  
  19.     $result = mysql_query("SELECT * FROM user ORDER BY userid DESC LIMIT 1");
  20.     while($row = mysql_fetch_array($result))
  21.     {
  22.         $id = $row['userid']+1;
  23.     }
  24.     if (!$con)
  25.   {
  26.   die('Could not connect: ' . mysql_error());
  27.   }
  28. /* default posts and userlevel */
  29. $posts = 0;
  30. //(admin 6),(normal user 1)
  31. $userlevel = 1;
  32.    
  33. /*-------------------------*/
  34. /* Start Registration here */
  35. /*-------------------------*/
  36. /**/
  37.  
  38. if (isset($_POST['submit']) == true) {
  39. $username = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $username);
  40. $password = preg_replace("/[^a-zA-Z0-9\-\_\!\$\#\@\^\&\*\(\)\^\+\ \.\?]/", "", $password);
  41. }
  42.  
  43. else if ((isset($_POST['submit']) == true) and (strlen($username) < 3) || (strlen($username) > 15)) {
  44. echo "Your username must be between 3 and 15 characters in length.";
  45. }
  46.  
  47. else if ((isset($_POST['submit']) == true) and ((strlen($password) < 3) || (strlen($password) > 32) || (strlen($rpassword) < 3) || (strlen($rpassword) > 32))) {
  48. echo "The password must be between 3 and 32 characters in length.";
  49. }
  50.  
  51. else if ((isset($_POST['submit']) == true) and ($password != $rpassword)) {
  52. echo "The passwords must be the same.";
  53. }
  54.  
  55. else if ((isset($_POST['submit']) == true) and (($username == $password) || ($username == $rpassword))) {
  56. echo "The username and password cannot be the same.";
  57. }
  58.  
  59. $sql = ("INSERT INTO user (userid, username, password, lastlog, posts, accessid)
  60. VALUES ('$id', '$username', '$password', '$date', '$userlevel')");
  61. else(isset($_POST['submit']) == true)
  62. {
  63. mysql_query($sql,$con);
  64. echo "username accepted, you have been registered";
  65. }
  66. die(mysql_error());
  67.    
  68.       mysql_close($con);
  69.  
  70.         ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement