Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3.  
  4. require_once("includes/config.php");
  5.  
  6. if (isset($_SESSION['admin']['id'])){
  7.  
  8. header("location: dashboard.php");
  9. exit();
  10. }
  11.  
  12. if(isset($_POST['login_btn'])){
  13.  
  14. $error = array();
  15.  
  16. $error = login();
  17.  
  18. if(!count($error)){
  19.  
  20. $check_user = "select * from `users` where email='".$_POST['username']."' and password='".$_post['password']."' ";
  21.  
  22. $result_user = mysql_query($check_user);
  23.  
  24. $result = mysql_fetch_assoc($result_user);
  25.  
  26. if(isset($result['id'])){
  27.  
  28. $_SESSION['admin'] = $result;
  29.  
  30. unset($_SESSION['admin']['password']);
  31.  
  32. header("location: dashboard.php");
  33. exit();
  34. }
  35. else{
  36.  
  37. /*$msg_red = "Please Enter login details";*/
  38.  
  39. header("location: dashboard.php");
  40. exit();
  41. }
  42. }
  43. }
  44.  
  45. ?>
  46.  
  47. <?php
  48.  
  49. function login(){
  50.  
  51. $error = array();
  52.  
  53. if(empty($_POST['email'])){
  54.  
  55. $error['email'] = "Please Enter Username";
  56.  
  57. }
  58. else if(!filter_var($_POST['email'],FILTER_VALIDATE_EMAIL)){
  59.  
  60. $error['email'] = "Please Provide Email";
  61. }
  62. else if(empty($_POST['password'])){
  63.  
  64. $error['password'] = "Please Enter Password";
  65. }
  66.  
  67. return $error;
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement