Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form class="login" id="login">
- <p class="title">Log in</p>
- <input type="text" placeholder="Username" id="username" autofocus/>
- <i class="fa material-icons md-14">account_box</i>
- <input type="password" placeholder="Password" id="password" />
- <i class="fa material-icons md-14">lock</i>
- <a href="#">Dimenticato la password?</a>
- <button onClick="btnLogin()">
- <i class="spinner"></i>
- <span class="state">Log in</span>
- </button>
- </form>
- function btnLogin() {
- alert("qui entra");
- var _username = document.getElementById("username").value;
- var _password = document.getElementById("password").value;
- alert(_username);
- alert(_password); /*questi si vedono*/
- $.get("../php/login.php", { username: _username , password: _password }, function(data) {
- console.log('post');
- if (data['loggedin'] == 1 && data['username'] != undefined)
- window.location.replace("../index.php");
- });
- }
- <?php
- session_start();
- $mysqli = new mysqli("localhost", "root", "MySQLRootPassword@Mecq2018", "gdc2");
- $query = "SELECT idutente, username FROM utente WHERE username=? AND password=MD5(?);";
- if ($stmt = $mysqli->prepare($query)) {
- $stmt->bind_param("ss", $_GET["username"], $_GET["password"]);
- $stmt->execute();
- $stmt->bind_result($result["idutente"], $result["username"]);
- $stmt->fetch();
- $stmt->close();
- }
- echo json_encode($result);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement