Advertisement
Guest User

Untitled

a guest
Jun 15th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 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. echo "SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
  19. $query = "SELECT * FROM $tbl_name WHERE username=? and password=?";
  20. $stmt = $connection->prepare($query);
  21. $stmt->bind_param('ss', $myusername, $mypassword);
  22. $stmt->execute();
  23. if($stmt->num_rows > 0){
  24.  
  25. session_register("myusername");
  26. session_register("mypassword");
  27. echo "Login Accepted";
  28. }
  29. else {
  30. echo "Wrong Username or Password";
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement