Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2. $host="localhost"; // Host name
  3. $username="test"; // Mysql username
  4. $password="pocakaj"; // Mysql password
  5. $db_name="game"; // Database name
  6. $tbl_name="game"; // Table name
  7.  
  8. // Connect to server and select databse.
  9. $connection = new mysqli($host, $username, $password, $db_name);
  10.  
  11. $myusername=$_POST['myusername'];
  12. $mypassword=$_POST['mypassword'];
  13.  
  14. //Should really just turn off magic quotes
  15. $myusername = stripslashes($myusername);
  16. $mypassword = stripslashes($mypassword);
  17.  
  18.  
  19. $query = "SELECT password FROM $tbl_name WHERE username=?";
  20. $stmt = $connection->prepare($query);
  21. $stmt->bind_param('s', $myusername);
  22. $stmt->execute();
  23. $stmt->bind_result($password);
  24. $stmt->fetch();
  25. if($stmt->num_rows > 0){
  26. if($password != $mypassword) {
  27. echo "Incorrect password";
  28. } else {
  29. session_register("myusername");
  30. session_register("mypassword");
  31. echo "Login Accepted";
  32. }
  33. }
  34. else {
  35. echo "Username not found";
  36. }
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement