Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
54
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. session_start();
  3. $serverhost = "localhost";
  4. $server_name = "root";
  5. $server_password = "";
  6. $dbName= "avatar fight";
  7.  
  8.  
  9. $username = $_POST["usernamePost"];
  10. $userpassword = $_POST["passwordPost"];
  11.  
  12. //Make Connection
  13. $conn = new mysqli($serverhost, $server_name, $server_password, $dbName);
  14.  
  15. //Check connection
  16. if(!$conn){
  17. die("Connection failed.". mysqli_connect_error());
  18. }
  19.  
  20. $sql= "SELECT user_id, user_password FROM user WHERE user_name = '".$username."' ";
  21. $result = mysqli_query($conn ,$sql);
  22.  
  23. //Get the result and Login
  24. if(mysqli_num_rows($result) > 0){
  25. //Show Data for each row
  26. while($row = mysqli_fetch_assoc($result)){
  27. if($row['user_password'] == $userpassword){
  28. echo "Logged in";
  29. $_SESSION['user_logged'] = $row['user_id'];
  30. //echo("{$_SESSION['user_logged']}");
  31. }
  32. else{
  33. echo "password wrong";
  34. }
  35. }
  36. } else {
  37. echo "User not found";
  38. }
  39.  
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement