Guest User

Untitled

a guest
Dec 22nd, 2018
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.09 KB | None | 0 0
  1. $email=$_POST['email'];
  2. $pass=$_POST['pass'];
  3. $_SESSION['type'] = 'user';
  4. $_SESSION['email'] = $email;
  5. $_SESSION['pass']=$pass;
  6. header('location:./connect.php');
  7.  
  8. if(empty($_SESSION))
  9. {
  10. session_regenerate_id();
  11. session_start();
  12. }
  13. @mysql_connect('localhost','root','') or die("ERROR in SERVER");
  14. @mysql_select_db('module') or die("ERROR IN DATABASE");
  15.  
  16. $_SESSION['start'] = time(); // taking now logged in time
  17.  
  18. if(!isset($_SESSION['expire'])){
  19. $_SESSION['expire'] = $_SESSION['start'] + (60* 60) ; // ending a session in 30 seconds
  20. }
  21. $now = time(); // checking the time now when home page starts
  22.  
  23. if($now > $_SESSION['expire'])
  24. {
  25. session_destroy();
  26.  
  27. }
  28.  
  29. if(!empty($_SESSION['type']))
  30. {
  31. $email = $_SESSION['email'];
  32. $pass = $_SESSION['pass'];
  33. $type = $_SESSION['type'];
  34.  
  35.  
  36. // admin login //
  37. if($type == 'admin'){
  38.  
  39.  
  40.  
  41.  
  42. $admin = mysql_query("SELECT * FROM `admin` WHERE `email` ='$email' ");
  43. $res = mysql_fetch_array($admin);
  44. if($email == "" || $pass == "" || $email != $res['email'] || $pass != $res['pass'])
  45. {
  46. header('location:./login/login.php');
  47. }
  48.  
  49. }
  50.  
  51.  
  52. // user login //
  53. if($type == 'user')
  54. {
  55. $email = $_SESSION['email'];
  56. $pass = $_SESSION['pass'];
  57. $type = $_SESSION['type'];
  58. $user = mysql_query("SELECT `id` FROM `users` WHERE `email`='$email' AND `status`='1'");
  59. $useres = mysql_fetch_array($user);
  60. // $trail = $useres['date'];
  61. // $time = explode("/",$trail);
  62.  
  63.  
  64. if($email != $useres['email'] || $pass != $useres['pass'])
  65.  
  66. {
  67. echo mysql_error();
  68. // header('location:./login/login.php');
  69. }
  70.  
  71. else if($pass = $useres['pass']){
  72. // echo '<script> location.replace("./user.php"); </script>';
  73. }
  74. }
  75.  
  76.  
  77. // agent login //
  78. if($type == 'agent')
  79. {
  80.  
  81. $email = $_SESSION['email'];
  82. $pass = $_SESSION['pass'];
  83. $type = $_SESSION['type'];
  84. $agent = mysql_query("SELECT `id` FROM `sale_agents` WHERE `email`='$email'");
  85. $agentres = mysql_fetch_array($agent);
  86. if($email != $agentres['email'] || $pass != $agentres['pass'])
  87. {
  88. header('location:./login/login.php');
  89.  
  90. }
  91. else if($pass = $agentres['pass']){
  92. // echo '<script> location.replace("./agent.php"); </script>';
  93. }
  94. }
  95. }
  96. else{
  97. header('location:./login/login.php');
  98. }
  99.  
  100. <?php
  101. session_start();
  102. ?>
  103.  
  104. <?php
  105. //This is page 1 and then we will use session that defined from this page:
  106. session_start();
  107. $_SESSION['email]='email@example.com';
  108. ?>
  109.  
  110. <?php
  111. //In this page I am going to use session:
  112. session_start();
  113. if($_SESSION['email']){
  114. echo 'Your Email Is Here! :) ';
  115. }
  116. ?>
  117.  
  118. <?php
  119. session_start();
  120. $email=$_POST['email'];
  121. $pass=$_POST['pass'];
  122. $_SESSION['type'] = 'user';
  123. $_SESSION['email'] = $email;
  124. $_SESSION['pass']=$pass;
  125. header('location:./connect.php');
  126. ?>
  127.  
  128. session_start();
  129. $email = $_POST['email'];
  130. $pass = $_POST['pass'];
  131. $_SESSION['type'] = 'user';
  132. $_SESSION['email'] = $email;
  133. $_SESSION['pass'] = $pass;
  134. header('location:./connect.php');
  135.  
  136. session_start();
  137. @mysql_connect('localhost', 'root', '') or die("ERROR in SERVER");
  138. @mysql_select_db('module') or die("ERROR IN DATABASE");
  139. $_SESSION['start'] = time(); // taking now logged in time
  140. if (!isset($_SESSION['expire'])) {
  141. $_SESSION['expire'] = $_SESSION['start'] + (60 * 60);
  142. }
  143. $now = time(); // checking the time now when home page starts
  144. if ($now > $_SESSION['expire']) {
  145. session_destroy();
  146. header('location:./login/login.php');
  147. }
  148. if (isset($_SESSION['email']) && !empty($_SESSION['email']) &&
  149. isset($_SESSION['pass']) && !empty($_SESSION['pass']) &&
  150. isset($_SESSION['type']) && !empty($_SESSION['type'])) {
  151.  
  152. $email = $_SESSION['email'];
  153. $pass = $_SESSION['pass'];
  154. $type = $_SESSION['type'];
  155.  
  156. // admin login //
  157. if ($type == 'admin') {
  158. $admin = mysql_query("SELECT * FROM `admin` WHERE `email`='$email'");
  159. $res = mysql_fetch_array($admin);
  160. if ($email == "" || $pass == "" || $email != $res['email'] || $pass != $res['pass']) {
  161. session_destroy();
  162. header('location:./login/login.php');
  163. }
  164. }
  165.  
  166. // user login //
  167. if ($type == 'user') {
  168. $user = mysql_query("SELECT `id` FROM `users` WHERE `email`='$email' AND `status`='1'");
  169. $useres = mysql_fetch_array($user);
  170. // $trail = $useres['date'];
  171. // $time = explode("/",$trail);
  172. if ($email != $useres['email'] || $pass != $useres['pass']) {
  173. session_destroy();
  174. header('location:./login/login.php');
  175. }
  176. }
  177.  
  178. // agent login //
  179. if ($type == 'agent') {
  180. $agent = mysql_query("SELECT `id` FROM `sale_agents` WHERE `email`='$email'");
  181. $agentres = mysql_fetch_array($agent);
  182. if ($email != $agentres['email'] || $pass != $agentres['pass']) {
  183. session_destroy();
  184. header('location:./login/login.php');
  185. }
  186. }
  187. } else {
  188. header('location:./login/login.php');
  189. }
  190.  
  191. $_SESSION["user"] = $result['full_name'];
  192. $_SESSION["user_id"] = $result['user_id'];
  193. $_SESSION["website_type"] = $result['user_id'];
  194.  
  195. echo $_SESSION['user'];
  196. echo $_SESSION['user_id'];
  197. echo $_SESSION['website_type'];
Add Comment
Please, Sign In to add comment