Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. <?php
  2.  
  3. if(isset($_POST['registerPHP' ] )){
  4.  
  5. try{
  6. $registerPHP = new registerPHP();
  7. $registerPHP->connect();
  8. }catch(Exception $e){echo $e->getMessage();}
  9.  
  10. }
  11.  
  12. if(isset($_POST['loginPHP' ] )){
  13.  
  14. try{
  15. $class = new loginPHP();
  16. }catch(Exception $e){echo $e->getMessage();}
  17.  
  18. }
  19.  
  20. class registerPHP{
  21.  
  22. public function __construct() {
  23.  
  24. }
  25.  
  26. public function connect() {
  27.  
  28. $dbip = "85.10.205.173:3306";
  29. $dbusername = "pretpacked";
  30. $dbpassword = "i6kfxTEYXs0rkQw16mPQ";
  31. $dbdatabase = "sdgger24w45672fe";
  32.  
  33. $con = mysqli_connect("$dbip", "$dbusername", "$dbpassword", "$dbdatabase");
  34.  
  35. if (mysqli_connect_errno()){
  36. echo "Failed to connect to MySQL: " . mysqli_connect_error();
  37. }else{$this->registerPHP($con);}
  38.  
  39.  
  40.  
  41. }
  42.  
  43. public function registerPHP($con = null){
  44.  
  45. if($con){echo "<br> black nibba, fuck these ; "; var_dump($con);}
  46.  
  47. $username = $_POST['usernameReg'];
  48. $password = $_POST['passwordReg'];
  49.  
  50. if(strlen($username) <= 4){
  51. throw new Exception(' <script> alert("Username is to small [4]")</script>' );
  52. }
  53. if(strlen($password) <= 6){
  54. throw new Exception(' <script> alert("Password is to small [6]")</script>' );
  55. }
  56.  
  57. $dbip = "***********";
  58. $dbusername = "***********";
  59. $dbpassword = "***********";
  60. $dbdatabase = "***********";
  61.  
  62. echo "<br>Username: $username";
  63. echo "<br>Password: $password";
  64. $password = password_hash($password, PASSWORD_DEFAULT);
  65. echo "<br>HASHED Password: $password <br><br>Output:";
  66.  
  67. $lgn="SELECT * FROM loginData WHERE lgn = '$username'";
  68. $addData = "INSERT INTO loginData ( lgn, pass) VALUES ( '$username', '$password' )";
  69.  
  70. if ($result=mysqli_query($con,$lgn)){
  71.  
  72. $rowcount=mysqli_num_rows($result);
  73. mysqli_free_result($result);
  74.  
  75. if($rowcount == 0){
  76.  
  77. echo "<br>Username free.";
  78.  
  79. if ($result=mysqli_query($con,$addData)){
  80.  
  81. if($rowcount == 0){
  82.  
  83. echo "<br>Data added";
  84. echo "<script>alert('Account created')</script>";
  85. echo "<script>window.open('http://localhost/index.php', '_blank')</script>";
  86.  
  87. }
  88.  
  89. }else{printf("<br>Data not added");}
  90.  
  91. }else{printf("<br>username result set has %d rows.\n",$rowcount);}
  92.  
  93. }
  94. echo "<br>==============================================================";
  95. mysqli_close($con);
  96. }
  97.  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement