Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2019
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.16 KB | None | 0 0
  1. //initialize the variables
  2. $username="";
  3. $password="";
  4. $_SESSION['username']="";
  5. $_SESSION['password']="";
  6. if(isset($_POST["submit"]) && @$_GET["username"] !==""){
  7. $username=$_POST["username"];
  8. $password=$_POST["password"];
  9. if(isset($_POST["username"]) && $_POST["username"]!=="" && isset($_POST["password"]) && $_POST["password"]!==""){
  10. //sucuring the data
  11. $username=htmlentities(mysql_real_escape_string(trim($_POST["username"])));
  12. $password=htmlentities(mysql_real_escape_string(trim($_POST["password"])));
  13. //checking if user does exist
  14. $sql="SELECT email, password FROM ".$db_name.".user WHERE email="".$username."" AND password='".md5($password)."' LIMIT 1";
  15. $query=mysql_query($sql,$con);
  16. $result=mysql_fetch_assoc($query);
  17. //check query to c if is successfully optional
  18. if(!$result){
  19. print"fuck me";
  20. }else{
  21. //if combination found in our database then register session values";
  22. $_SESSION['username']=$_POST['username'];
  23. $_SESSION['password']=md5($_POST['password']);
  24. //check location
  25. $sql="SELECT location FROM ".$db_name.". user WHERE email ='".$_POST['username']."' LIMIT 1";
  26. $query=mysql_query($sql,$con);
  27. $result=mysql_fetch_array($query);
  28. //no need of loop since we want only one field/single record/row
  29. $location=$result['location'];
  30. header("Location:".$location."");
  31. }
  32. }else{
  33. //do nothing
  34. }
  35.  
  36. }
  37.  
  38. ?>
  39. <form id="loginFrm" method="post" action="?lgn=getin">
  40. <fieldset>
  41. <legend>
  42. Inshuz Login
  43. </legend>
  44. <table>
  45. <tr>
  46. <td>
  47. Username
  48. <div id="specify">Your email</div>
  49. </td>
  50. <td>
  51. <input type="text" name="username" size="40" class="text" value="<?php print $username; ?>">
  52. </td>
  53. </tr>
  54. <tr>
  55. <td>
  56. Password
  57. </td>
  58. <td>
  59. <input type="password" name="password" size="40" class="text" value="<?php print $password; ?>">
  60. </td>
  61. </tr>
  62. <tr>
  63. <td colspan="2">
  64. <input type="submit" name="submit" class="btn" value="Login">
  65. <td>
  66. </tr>
  67. </table>
  68. </fieldset>
  69. </form>
  70.  
  71. <?php session_start(); require_once("includes/functions/url.php"); require_once("includes/config/config.php");?>
  72. <html>
  73. <head>
  74. <title>
  75.  
  76. </title>
  77. <head>
  78. <link rel="stylesheet" media="all" type="text/css" href="css/main.css"/>
  79. <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
  80. <body>
  81. <div id="wrapper">
  82. <div id="header">
  83. <div id="nav">
  84. <a href="#">Home </a> | <a href="#">About us</a> | <a href="#">Products</a> | <a href="#">Services</a> | <a href="#">Carrers</a>
  85. </div>
  86. </div><!--end of header-->
  87. <div id="mainContent">
  88. <div id="RighContent">
  89. <?php require_once("includes/pages/".@$page);?>
  90. </div><!---RightCont--->
  91. <div id="LeftCont">
  92. afafhkashf
  93. </div><!---leftcont--->
  94. </div><!---end of maincontent-->
  95. <div id="footer">
  96.  
  97. </div><!--end footer-->
  98. </div><!--end of wrapper-->
  99. <body>
  100. </html>
  101.  
  102. <?php session_start();
  103. require_once("includes/functions/url.php");
  104. if(!isset($_SESSION['username'])){
  105. header("Location: ../");
  106. exit();
  107. }
  108. ?>
  109. <html>
  110. <head>
  111. <title>
  112.  
  113. </title>
  114. <head>
  115. <link rel="stylesheet" media="all" type="text/css" href="css/main.css"/>
  116. <script type="text/javascript" src="js/jquery-1.8.0.js"></script>
  117. <body>
  118. <div id="wrapper">
  119. <div id="header">
  120. <div id="nav">
  121. <a href="#">Home </a> | <a href="#">About us</a> | <a href="#">Products</a> | <a href="#">Services</a> | <a href="#">Carrers</a>
  122. <?php
  123. //show logout
  124. if(isset($_SESSION['username'], $_SESSION['password'])){
  125. print " | <a href="includes/pages/logout.php?log=logout">Logout</a>";
  126. }
  127. ?>
  128. </div>
  129. </div><!--end of header-->
  130. <div id="mainContent">
  131. <div id="RighContent">
  132. <h1>Welcome admin: <?php print @$_SESSION['username']; ?></h1>
  133. </div><!---RightCont--->
  134. <div id="LeftCont">
  135. afafhkashf
  136. </div><!---leftcont--->
  137. </div><!---end of maincontent-->
  138. <div id="footer">
  139.  
  140. </div><!--end footer-->
  141. </div><!--end of wrapper-->
  142. <body>
  143.  
  144.  
  145. </html>
  146.  
  147. <?php
  148. ini_set('session.use_trans_sid', false);
  149. session_start();
  150. //require_once("includes/functions/url.php");
  151. if(isset($_GET['log']) && $_GET['log']=="logout"){
  152. if(isset($_SESSION['username'] , $_SESSION['password']) && !empty($_SESSION['username']) && !empty($_SESSION['password'] )){
  153. unset($_SESSION['username']);
  154. unset($_SESSION['password']);
  155. header("Location: ../../");
  156. exit();
  157. }
  158. }
  159. ?>
  160.  
  161. unset($_SESSION);
  162. session_destroy();
  163.  
  164. <?php
  165. ini_set('session.use_trans_sid', false);
  166. session_start();
  167. //require_once("includes/functions/url.php");
  168. if(isset($_GET['log']) && $_GET['log']=="logout"){
  169. if(isset($_SESSION['username'] , $_SESSION['password']) && !empty($_SESSION['username']) && !empty($_SESSION['password'] )){
  170. unset($_SESSION['username']);
  171. unset($_SESSION['password']);
  172. header("Location: ../../");
  173. exit();
  174. }
  175. }
  176. ?>
  177.  
  178. header('cache-control: no-cache,no-store,must-revalidate'); // HTTP 1.1.
  179. header('pragma: no-cache'); // HTTP 1.0.
  180. header('expires: 0'); // Proxies.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement