Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3. $("#submit").click(function() {
  4. var dataString = {
  5. username: $("#username").val(),
  6. password: $("#password").val(),
  7. };
  8. $.ajax({
  9. type: "POST",
  10. url: "login-process.php",
  11. data: dataString,
  12. cache: true,
  13. beforeSend: function(){
  14. $('#loading-image').show();
  15. },
  16. complete: function(){
  17. $('#loading-image').hide();
  18. },
  19. success: function(html){
  20. $('.message').html(html).fadeIn(2000);
  21. setTimeout(function(){ window.location.replace("dashboard.php"); }, 2000);
  22. }
  23. });
  24. return false;
  25. });
  26. });
  27. </script>
  28.  
  29. <?php
  30. include'config/db.php';
  31. $msg = null;
  32. $date = date('Y-m-d H:i:s');
  33.  
  34. $uname = (!empty($_POST['username']))?$_POST['username']:null;
  35. $pass = (!empty($_POST['password']))?$_POST['password']:null;
  36.  
  37. if($_POST){
  38. $stmt = "SELECT * FROM members WHERE mem_uname = :uname";
  39. $stmt = $pdo->prepare($stmt);
  40. $stmt->bindValue(':uname', $uname);
  41. $stmt->execute();
  42. $checklgn = $stmt->rowCount();
  43. $fetch = $stmt->fetch();
  44.  
  45. if($checklgn > 0){
  46. if(password_verify($pass, $fetch['mem_pass'])){
  47. session_start();
  48. $_SESSION['sanlogin'] = $fetch['mem_id'];
  49. $msg = "<div class='message-success'>Access Granted! Please wait...</div>";
  50. }else{
  51. $msg = "<div class='message-error'>Password mismatch. Please try again!</div>";
  52. }
  53. }else{
  54. $msg = "<div class='message-error'>User not found. Please try again!</div>";
  55. }
  56. }
  57. echo $msg;
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement