Advertisement
Guest User

Untitled

a guest
Jul 5th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.72 KB | None | 0 0
  1. <?php
  2. include ('includes/config.php');
  3. global $con;
  4.  
  5. if (isset($_POST['btn-login'])) {
  6.  
  7. // Initialize a session:
  8. session_start();
  9.  
  10. $error = array(); //this aaray will store all error messages
  11.  
  12.  
  13. if (empty($_POST['email'])) { //if the email supplied is empty
  14. $error[] = 'You forgot to enter your Email ';
  15. $msg_error_email= 'You forgot to enter your Email';
  16. } else {
  17.  
  18. $Email = mysqli_real_escape_string($con, $_POST['email']);
  19. $Email = stripslashes($Email);
  20. }
  21.  
  22. if (empty($_POST['password'])) {
  23. $error[] = 'Please Enter Your Password ';
  24. $msg_error_pass= 'Please Enter Your Password';
  25. } else {
  26. $Password = mysqli_real_escape_string($con, md5($_POST['password']));
  27. $Password = stripslashes($Password);
  28. }
  29.  
  30.  
  31. if (empty($error))//if the array is empty , it means no error found
  32. {
  33.  
  34.  
  35. $query_check_credentials = "SELECT * FROM m_admins WHERE (admin_password='$Password' AND admin_email='$Email') AND admin_auth='ACTIVE'";
  36.  
  37.  
  38. $result_check_credentials = mysqli_query($con, $query_check_credentials) or die (mysqli_error($con));
  39.  
  40. //if Query is successfull
  41. if (mysqli_num_rows($result_check_credentials))
  42. {
  43.  
  44. $_SESSION['admin_email']=$Email; // Initializing Session
  45.  
  46. echo "<script>alert('You Logged in Sucessfully... Thanks!!')</script>";
  47. echo "<script>window.open('index.php','_self')</script>";
  48.  
  49.  
  50. }else
  51. {
  52.  
  53. $msg_error1= 'Either Your Account is inactive or Email address / Password is Incorrect';
  54.  
  55. }
  56.  
  57. }
  58.  
  59.  
  60. }
  61.  
  62.  
  63. ?>
  64.  
  65. <!DOCTYPE html>
  66. <html lang="en">
  67.  
  68. <head>
  69.  
  70. <meta charset="utf-8">
  71. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  72. <meta name="viewport" content="width=device-width, initial-scale=1">
  73. <meta name="description" content="">
  74. <meta name="author" content="">
  75.  
  76. <title>Demo App | Login</title>
  77.  
  78. </head>
  79.  
  80. <body>
  81.  
  82. <div class="container">
  83. <div class="row">
  84. <div class="col-md-4 col-md-offset-4">
  85. <div style="margin-top:100px; margin-bottom:-50px;">
  86. <?php if(isset($_GET['logout'])) {
  87. echo '<div class="alert alert-success">
  88. <button class="close" data-dismiss="alert">&times;</button>
  89. <strong>Thanks ! </strong> You have successfully loged out.. </div> ';
  90. }
  91. ?>
  92. </div>
  93.  
  94. <div class="login-panel panel panel-default">
  95. <div class="panel-heading">
  96. <h3 class="panel-title">Please Sign In</h3>
  97. </div>
  98. <div class="panel-body">
  99. <form action="login.php" method="post" role="form">
  100.  
  101. <!-- ========= Sucess/Error will display here =========== -->
  102.  
  103. <?php if(isset($msg_error1)) {
  104. echo '<div class="alert alert-danger">
  105. <button class="close" data-dismiss="alert">&times;</button>
  106. <strong>Sorry ! </strong>' .$msg_error1. '</div> ';
  107. } ?>
  108.  
  109. <?php if(isset($msg_error_email)) {
  110. echo '<div class="alert alert-warning">
  111. <button class="close" data-dismiss="alert">&times;</button>
  112. <strong>' .$msg_error_email. '</strong></div> ';
  113. } ?>
  114.  
  115. <fieldset>
  116. <div class="form-group">
  117. <input class="form-control" placeholder="E-mail" name="email" type="email" autofocus>
  118. </div>
  119.  
  120. <?php if(isset($msg_error_pass)) {
  121. echo '<div class="alert alert-warning">
  122. <button class="close" data-dismiss="alert">&times;</button>
  123. <strong>' .$msg_error_pass. '</strong></div> ';
  124. } ?>
  125.  
  126. <div class="form-group">
  127. <input class="form-control" placeholder="Password" name="password" type="password" value="">
  128. </div>
  129. <div class="checkbox">
  130. <label>
  131. <input name="remember" type="checkbox" value="Remember Me">Remember Me
  132. </label>
  133. </div>
  134. <button type="submit" class="btn btn-lg btn-success btn-block" name="btn-login">Login</button>
  135. </fieldset>
  136. </form>
  137. </div>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142.  
  143. <!-- jQuery -->
  144. <script src="login_files/bower_components/jquery/dist/jquery.min.js"></script>
  145.  
  146. <!-- Bootstrap Core JavaScript -->
  147. <script src="login_files/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
  148.  
  149. <!-- Metis Menu Plugin JavaScript -->
  150. <script src="login_files/bower_components/metisMenu/dist/metisMenu.min.js"></script>
  151.  
  152. <!-- Custom Theme JavaScript -->
  153. <script src="login_files/dist/js/sb-admin-2.js"></script>
  154.  
  155. </body>
  156.  
  157. </html>
  158.  
  159. <?php
  160. include('includes/config.php');
  161. session_start(); // Use session variable on this page. This function must put on the top of page.
  162.  
  163. if (!isset($_SESSION['admin_email'])) {
  164. echo "<script>window.open('login.php','_self')</script>";
  165. }
  166.  
  167. else
  168. {
  169. global $con;
  170. date_default_timezone_set('Asia/Kolkata');
  171.  
  172. $date = date('Y-m-d H:i:s');
  173. $user = $_SESSION['admin_email'];
  174. $ip = $_SERVER['REMOTE_ADDR'];
  175.  
  176. $update_last_login="UPDATE m_admins SET admin_status='ONLINE',admin_last_login='$date',active_ip_address='$ip' WHERE admin_email='$user'";
  177.  
  178. $update_last_login = mysqli_query($con, $update_last_login) or die (mysqli_error($con));
  179.  
  180. ?>
  181.  
  182. <!DOCTYPE html>
  183. <html>
  184. <head>
  185. <meta charset="UTF-8">
  186. <title>Demo App | Welcome </title>
  187. <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
  188. <meta name="description" content="">
  189. <meta name="keywords" content="">
  190. </head>
  191. <body class="skin-black">
  192.  
  193.  
  194. <div class="user-panel">
  195. <div class="pull-left info">
  196. <p>Hello,
  197. <?php if(isset($_SESSION['admin_email'])){
  198. echo "".ucfirst($_SESSION['admin_name']);
  199. }
  200. ?>
  201. </p>
  202. </div>
  203. </div>
  204.  
  205.  
  206. </body>
  207. </html>
  208.  
  209. <?php
  210. }
  211. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement