Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. $db_host = "localhost"; //this is where we write inn the host of the server we are trying to conect to
  2. $db_username = "root"; //we write in the username and the password we were given by olaf.
  3. $db_pass = "usn";
  4. $db_name = "dayz_1";// here we write in the name of the database we are trying to conect to
  5.  
  6. // get values pass from form in index.php file
  7. $username = $POST['user'];
  8. $password = $POST['pass'];
  9.  
  10. //to prevent injection from mysql
  11. $username = stripcslashes($username);
  12. $password = stripcslashes($password);
  13. $username = mysqli_real_escape_string($username);
  14. $password = mysqli_real_escape_string($password);
  15.  
  16. //Connect to the server and select database.
  17. $link = mysqli_connect("localhost", "root", "usn", "dayz_1");
  18.  
  19. //Query the database for user
  20. $result = $mysqli_query("select * from login where username = '$username' and password = '$password'")
  21. or die("Failed to query database ".mysqli_connect_error());
  22. $row = mysqli_fetch_array($result);
  23. if ($row['username'] == $username && $row['$password'] == $password){
  24. echo"login success! welcome " .$row['username'];
  25. } else {
  26. echo "failed to login!";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement