Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <form class="login" id="login">
  2. <p class="title">Log in</p>
  3. <input type="text" placeholder="Username" id="username" autofocus/>
  4. <i class="fa material-icons md-14">account_box</i>
  5. <input type="password" placeholder="Password" id="password" />
  6. <i class="fa material-icons md-14">lock</i>
  7. <a href="#">Dimenticato la password?</a>
  8. <button onClick="btnLogin()">
  9. <i class="spinner"></i>
  10. <span class="state">Log in</span>
  11. </button>
  12. </form>
  13.  
  14.  
  15. function btnLogin() {
  16. alert("qui entra");
  17.  
  18. var _username = document.getElementById("username").value;
  19. var _password = document.getElementById("password").value;
  20.  
  21. alert(_username);
  22. alert(_password); /*questi si vedono*/
  23.  
  24. $.get("../php/login.php", { username: _username , password: _password }, function(data) {
  25. console.log('post');
  26. if (data['loggedin'] == 1 && data['username'] != undefined)
  27. window.location.replace("../index.php");
  28. });
  29. }
  30.  
  31.  
  32.  
  33. <?php
  34. session_start();
  35. $mysqli = new mysqli("localhost", "root", "MySQLRootPassword@Mecq2018", "gdc2");
  36.  
  37. $query = "SELECT idutente, username FROM utente WHERE username=? AND password=MD5(?);";
  38.  
  39. if ($stmt = $mysqli->prepare($query)) {
  40. $stmt->bind_param("ss", $_GET["username"], $_GET["password"]);
  41. $stmt->execute();
  42. $stmt->bind_result($result["idutente"], $result["username"]);
  43. $stmt->fetch();
  44. $stmt->close();
  45. }
  46.  
  47. echo json_encode($result);
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement