Advertisement
afischer

Untitled

Aug 11th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'config.inc.php';
  4. class login1 extends DB{
  5.  
  6. public $username;
  7. public $password;
  8. public $checknum;
  9. public $inusername;
  10.  
  11.  
  12. public function checkifuseronline($inusername){
  13.  
  14. $DB = new DB();
  15. $DB->connect();
  16.  
  17. $this->inusername = $DB->secret($inusername);
  18.  
  19.  
  20. $getuser = $DB->prepare("SELECT * FROM users WHERE username=?");
  21. $getuser->bind_Param("s", $this->inusername);
  22. $getuser->execute();
  23. $getuser->store_result();
  24. $getuser->num_rows;
  25. $this->checknum = $getuser->num_rows;
  26.  
  27. if($this->checknum == "1"){
  28.  
  29. header("location: profile.php");
  30. echo $this->checknum;
  31.  
  32. }else{
  33.  
  34. }
  35.  
  36.  
  37. }
  38.  
  39. public function login($username, $password){
  40.  
  41.  
  42. $DB = new DB();
  43. $DB->connect();
  44.  
  45.  
  46.  
  47. $this->username = $DB->secret($username);
  48. $this->password = $DB->secret($password);
  49.  
  50. $getuser = $DB->prepare("SELECT * FROM users WHERE username=? and password=?");
  51. $getuser->bind_Param("ss", $this->username, $this->password);
  52. $getuser->execute();
  53. $getuser->store_result();
  54. $getuser->num_rows;
  55. $this->checknum = $getuser->num_rows;
  56.  
  57. if($this->checknum == "1"){
  58.  
  59. $_SESSION['inuser'] = $this->username;
  60.  
  61. header("location: profile.php");
  62. echo $this->checknum;
  63.  
  64. }else{
  65. echo "Fel användarnamn eller lösenord.";
  66. }
  67.  
  68. }
  69.  
  70. public $firstname;
  71. public $lastname;
  72. public $username1;
  73. public $password1;
  74. public $email;
  75. public $birth;
  76. public $register_date;
  77. public $ip;
  78. public $userfound1;
  79. public $picture;
  80. public $rank;
  81. public $banned;
  82.  
  83.  
  84. public function register1($firstname, $lastname, $username1, $password1, $email, $birth, $register_date, $ip){
  85.  
  86. $DB = new DB();
  87. $DB->connect();
  88.  
  89. $this->id = "";
  90. $this->firstname = $DB->secret($firstname);
  91. $this->lastname = $DB->secret($lastname);
  92. $this->username1 = $DB->secret($username1);
  93. $this->password1 = $DB->secret($password1);
  94. $this->email = $DB->secret($email);
  95. $this->birth = $DB->secret($birth);
  96. $this->register_date = $DB->secret($register_date);
  97. $this->ip = $DB->secret($ip);
  98. $this->picture = "images/newuser.png";
  99. $this->rank = "0";
  100. $this->banned = "0";
  101.  
  102.  
  103. // checkar av om användaren redan finns
  104.  
  105. $userfound = $DB->prepare("SELECT * FROM users WHERE username = ? or email = ?");
  106. $userfound->bind_Param("ss", $this->username, $this->email);
  107. $userfound->execute();
  108. $userfound->store_result();
  109. $userfound->num_rows;
  110. $this->userfound1 = $userfound->num_rows;
  111.  
  112. if($this->userfound1 == "1"){
  113.  
  114. echo "Användarnamnet eller emailen är redan registerad...";
  115.  
  116.  
  117. }else{
  118.  
  119. // sätter in användaren i databasen
  120.  
  121. $insertuser = $DB->prepare("INSERT INTO users (id, username, password, firstname, lastname, email, birth, picture, register_date, rank, banned, ip)VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
  122. $insertuser->bind_Param("ssssssssssss", $this->id, $this->username1, $this->password1, $this->firstname, $this->lastname, $this->email, $this->birth, $this->picture, $this->register_date, $this->rank, $this->banned, $this->ip);
  123. $insertuser->execute();
  124.  
  125. if($this->userfound1 == "1"){
  126.  
  127. echo "Du är nu registerad klicka <a href='index.php'>här</a> för att logga...";
  128.  
  129. }
  130. }
  131. }
  132.  
  133. public $onlinename;
  134. public $checkonline;
  135.  
  136. public function getuserinfo($onlinename){
  137.  
  138. $DB = new DB();
  139. $DB->connect();
  140.  
  141. $this->onlinename = $DB->secret($onlinename);
  142.  
  143. $stmt = $DB->prepare("SELECT * FROM users WHERE username = ?");
  144. $stmt->bind_Param("s", $this->onlinename);
  145. $stmt->execute();
  146. $stmt->store_result();
  147. $stmt->num_rows;
  148. $this->checkonline = $stmt->num_rows;
  149.  
  150. if($this->checkonline == "1"){
  151. $stmt->bind_result($id, $username, $password, $firstname, $password, $email, $birth, $picture, $register_date, $rank, $banned, $ip);
  152. while($stmt->fetch()){
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. }
  161.  
  162. }else{
  163.  
  164. }
  165.  
  166.  
  167.  
  168. }
  169.  
  170.  
  171. }
  172.  
  173. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement