Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- $(document).ready(function() {
- $("#submit").click(function() {
- var dataString = {
- username: $("#username").val(),
- password: $("#password").val(),
- };
- $.ajax({
- type: "POST",
- url: "login-process.php",
- data: dataString,
- cache: true,
- beforeSend: function(){
- $('#loading-image').show();
- },
- complete: function(){
- $('#loading-image').hide();
- },
- success: function(html){
- $('.message').html(html).fadeIn(2000);
- setTimeout(function(){ window.location.replace("dashboard.php"); }, 2000);
- }
- });
- return false;
- });
- });
- </script>
- <?php
- include'config/db.php';
- $msg = null;
- $date = date('Y-m-d H:i:s');
- $uname = (!empty($_POST['username']))?$_POST['username']:null;
- $pass = (!empty($_POST['password']))?$_POST['password']:null;
- if($_POST){
- $stmt = "SELECT * FROM members WHERE mem_uname = :uname";
- $stmt = $pdo->prepare($stmt);
- $stmt->bindValue(':uname', $uname);
- $stmt->execute();
- $checklgn = $stmt->rowCount();
- $fetch = $stmt->fetch();
- if($checklgn > 0){
- if(password_verify($pass, $fetch['mem_pass'])){
- session_start();
- $_SESSION['sanlogin'] = $fetch['mem_id'];
- $msg = "<div class='message-success'>Access Granted! Please wait...</div>";
- }else{
- $msg = "<div class='message-error'>Password mismatch. Please try again!</div>";
- }
- }else{
- $msg = "<div class='message-error'>User not found. Please try again!</div>";
- }
- }
- echo $msg;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement