Advertisement
Guest User

Untitled

a guest
Aug 16th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.80 KB | None | 0 0
  1. <?php
  2. ###########################################################
  3. /*
  4. This software belongs to DSKC.TK using it without the explicit
  5. permission of the owner is strictly prohibited
  6. No modifications should be made to this file without a permission from
  7. the creator of this file
  8. Please contact DSKC.TK for further instructions.
  9. */
  10. ###########################################################
  11. session_name('LoginForm');
  12. @session_start();
  13.  
  14. error_reporting(0);
  15. include("config.php");
  16.  
  17.  
  18. if($_SERVER["REQUEST_METHOD"] == "POST") {
  19. // username and password sent from form
  20.  
  21. $myusername = mysqli_real_escape_string($db,$_POST['email']);
  22. $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  23.  
  24. $sql = "SELECT id FROM admin WHERE email = '$myusername' and passcode = '$mypassword'";
  25. $result = mysqli_query($db,$sql);
  26. $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  27. $active = $row['active'];
  28.  
  29. $count = mysqli_num_rows($result);
  30.  
  31.  
  32. // If result matched $myusername and $mypassword, table row must be 1 row
  33.  
  34. if($count == 1) {
  35. session_register("myusername");
  36. $_SESSION['login_user'] = $myusername;
  37.  
  38. header("location: table.php");
  39. }else {
  40. $error = "Your Login Name or Password is invalid";
  41. }
  42. }
  43. ?>
  44.  
  45.  
  46.  
  47.  
  48. <!DOCTYPE html>
  49. <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
  50. <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
  51. <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
  52. <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
  53. <head>
  54. <meta charset="utf-8">
  55. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  56. <title>Login Form</title>
  57. <meta name="description" content="">
  58. <meta name="viewport" content="width=device-width, initial-scale=1">
  59.  
  60.  
  61.  
  62. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  
  63.           <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  
  64.           <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  65.  
  66. <meta name="viewport" content="width=device-width, initial-scale=1">
  67.  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  68.  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  69.  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  70.  
  71.  
  72.  
  73. <!-- Stuff ends here-->
  74. </head>
  75. <body>
  76. <?php
  77. $error = '';
  78. if(isset($_POST['is_login'])){
  79. $sql = "SELECT * FROM ".$SETTINGS["USERS"]." WHERE `email` = '".mysql_real_escape_string($_POST['email'])."' AND `password` = '".mysql_real_escape_string($_POST['password'])."'";
  80. $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
  81. $user = mysql_fetch_assoc($sql_result);
  82. if(!empty($user)){
  83. $_SESSION['user_info'] = $user;
  84. }
  85. else{
  86. $error = 'Wrong email or password.';
  87. }
  88. }
  89.  
  90. if(isset($_GET['ac']) && $_GET['ac'] == 'logout'){
  91. $_SESSION['user_info'] = null;
  92. unset($_SESSION['user_info']);
  93. }
  94.  
  95. ?>
  96.  
  97.  
  98.  
  99.  
  100. <?php if(isset($_SESSION['user_info']) && is_array($_SESSION['user_info'])) { ?>
  101. <form id="login-form" name="form1"> <!-- paste here -->
  102.  
  103. <div id="form-content">
  104. <div class="welcome">
  105. <?php echo $_SESSION['user_info']['name'] ?>, you are logged in.
  106. <p> Go here <a href="http://dd.22web.org/Test/table.php"> click me </a>
  107. <br /><br />
  108.  
  109.  
  110. <?php echo $_SESSION['user_info']['content'] ?>
  111. <br /><br />
  112.  
  113.  
  114. <a href="index.php?ac=logout" style="color:#3ec038">Logout</a>
  115. </div>
  116. </div>
  117.  
  118. </form>
  119.  
  120.  
  121. <?php } else { ?>
  122. <form id="login-form" class="login-form" name="form1" method="post" action="index.php">
  123. <input type="hidden" name="is_login" value="1">
  124. <div class="h1">Login Form</div>
  125. <div id="form-content">
  126. <div class="group">
  127. <label for="email">Email</label>
  128. <div><input id="email" name="email" class="form-control required" type="email" placeholder="Email"></div>
  129. </div>
  130. <div class="group">
  131. <label for="name">Password</label>
  132. <div><input id="password" name="password" class="form-control required" type="password" placeholder="Password"></div>
  133. </div>
  134. <?php if($error) { ?>
  135. <em>
  136. <label class="err" for="password" generated="true" style="display: block;"><?php echo $error ?></label>
  137. </em>
  138. <?php } ?>
  139. <div class="group submit">
  140. <label class="empty"></label>
  141. <div><input name="submit" type="submit" value="Submit"/></div>
  142. </div>
  143. </div>
  144. <div id="form-loading" class="hide"><i class="fa fa-circle-o-notch fa-spin"></i></div>
  145. </form>
  146. <?php } ?>
  147. </body>
  148. </html>
  149.  
  150. <?php
  151. ###########################################################
  152. /*
  153. This software belongs to DSKC.TK modifying or usage of this file is strictly
  154. prohibited without an explicit permission from the creator.
  155. */
  156. ###########################################################
  157.  
  158. /* Define MySQL connection details and database table name */
  159. $SETTINGS["hostname"] = '';
  160. $SETTINGS["mysql_user"] = '';
  161. $SETTINGS["mysql_pass"] = '';
  162. $SETTINGS["mysql_database"] = '';
  163. $SETTINGS["USERS"] = 'php_users_login'; // this is the default table name that we used
  164.  
  165. /* Connect to MySQL */
  166. $connection = mysql_connect($SETTINGS["hostname"], $SETTINGS["mysql_user"], $SETTINGS["mysql_pass"]) or die ('Unable to connect to MySQL server.<br ><br >Please make sure your MySQL login details are correct.');
  167. $db = mysql_select_db($SETTINGS["mysql_database"], $connection) or die ('request "Unable to select database."');
  168. ?>
  169.  
  170. <?php
  171. ###########################################################
  172. /*
  173. This software belongs to DSKC.TK using it without the explicit
  174. permission of the owner is strictly prohibited
  175. No modifications should be made to this file without a permission from
  176. the creator of this file
  177. Please contact DSKC.TK for further instructions.
  178. */
  179. ###########################################################
  180. include('session.php');
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187. ?>
  188.  
  189. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  190. <html xmlns="http://www.w3.org/1999/xhtml">
  191. <head>
  192. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  193. <title>Table</title>
  194. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
  195. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
  196. <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
  197.  
  198. <meta name="viewport" content="width=device-width, initial-scale=1">
  199. <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  200. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  201. <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  202.  
  203. </head>
  204.  
  205. <body>
  206. ...
  207. </body>
  208. </html>
  209.  
  210. <?php
  211. include('config.php');
  212. session_start();
  213.  
  214. $user_check = $_SESSION['login_user'];
  215.  
  216. $ses_sql = mysqli_query($db,"select username from admin where username = '$user_check' ");
  217.  
  218. $row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
  219.  
  220. $login_session = $row['email'];
  221.  
  222. if(!isset($_SESSION['login_user'])){
  223. header("location: index.php");
  224. }
  225. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement