Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).on("submit", ".loginForm", function(event) {
- event.preventDefault();
- var url=$(this).attr("action");
- $.ajax({
- url: url,
- type: 'POST',
- data: new FormData(this),
- processData: false,
- contentType: false,
- datatype: "json",
- success: function (data, status)
- {
- if(data.success == "success"){
- window.location.replace("dashboard.php");
- } else {
- $('#loginResponse').html(data.success).css("color", "red").fadeIn().delay(2000).slideToggle();
- }
- }
- });
- header("Content-Type: application/json", true);
- if(isset($_POST['submit_login'])) {
- $username = $_POST['username'];
- $password = $_POST['password'];
- $sql = 'SELECT user_id, first_name, password FROM arbor_admin_users WHERE username=?';
- $stmt = $connection->prepare($sql);
- $stmt->bind_param('s', $username);
- $stmt->bind_result($uid, $fn, $pwhash);
- $stmt->execute();
- $stmt->store_result();
- if($stmt->num_rows > 0) {
- while($stmt->fetch()){
- // if ($password === $pw) {
- if (password_verify($password, $pwhash)) {
- session_start();
- $_SESSION['logged_in'] = $uid;
- $_SESSION['firstname'] = $fn;
- // header("Location: ../dashboard.php");
- echo json_encode(array('success'=>"success"));
- exit();
- } else {
- echo json_encode(array('success'=>"Wrong username or password!"));
- }
- }
- } else {
- echo json_encode(array('success'=>"Wrong username or password!"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement