Guest User

Untitled

a guest
Oct 19th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.85 KB | None | 0 0
  1. <?php
  2. //Database connection
  3. require_once('dashboard/config/connection.php');
  4. session_start();
  5.  
  6. //If the user has submitted the form
  7. if(isset($_REQUEST['username'])){
  8. //protect the posted value then store them to variables
  9. $username=mysqli_real_escape_string($dbc,$_POST['username']);
  10. $password=mysqli_real_escape_string($dbc,md5($_POST['password']));
  11. //Check if the username or password boxes were not filled in
  12. if(!$username || !$password){
  13. //if not display an error message
  14. echo "<center>You need to fill in a <b>Username</b> and a <b>Password</b>!</center>";
  15. }else{
  16.  
  17. $username=mysqli_real_escape_string($dbc,$_POST['username']);
  18. $password=mysqli_real_escape_string($dbc,md5($_POST['password']));
  19.  
  20. //Creating Session user
  21. $_SESSION['user']= $username;
  22.  
  23. $qry="SELECT username, password FROM users
  24. WHERE username='$username'
  25. AND password='$password';";
  26. $r=@mysqli_query($dbc,$qry);
  27. $row=@mysqli_num_rows($r);
  28. $rows=@mysqli_fetch_array($r,MYSQLI_ASSOC);
  29.  
  30.  
  31. if($row<=0){
  32. echo "<div class='isa_warning'>Check your Username and/ or Password and Try again.</div>";
  33. }
  34. else{
  35.  
  36. $qrys="SELECT username, user_id, type FROM users WHERE username='$username'";
  37. $rs=@mysqli_query($dbc,$qrys);
  38. $rws=@mysqli_num_rows($rs);
  39. $rw=@mysqli_fetch_array($rs,MYSQLI_ASSOC);
  40. $_SESSION['type']=$rw['type'];
  41. $_SESSION['user_id']=$rw['user_id'];
  42.  
  43. if($rws<=''){
  44. echo "<div class='isa_warning'>You do not have rights to access the system, Please contact the Administrator </div>";
  45. }else{
  46.  
  47.  
  48.  
  49. $user_group=$rw['type'];
  50. $_SESSION['user_group']=$user_group;
  51.  
  52. $_SESSION['user'] = $rw['username'];
  53.  
  54. $_SESSION['type'] = $user_group;
  55.  
  56. echo $user_group;
  57.  
  58. }
  59.  
  60. }
  61.  
  62. }
  63.  
  64. exit();
  65. }
  66. ?>
  67.  
  68. <div id="isa_warning"></div>
  69. <form id="loginForm" method="post" name="login" action="index.php">
  70. <label for="username">Email:</label>
  71. <input type="text" id="username" required name="username">
  72. <label for="password">Password:</label>
  73. <input type="password" id="password" required name="password">
  74. <div id="lower">
  75. <input type="submit" value="Login">
  76. </div><!--/ lower-->
  77. </form>
  78.  
  79. <script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
  80. <script type="text/javascript">
  81.  
  82. $( "#loginForm" ).submit(function( event ) {
  83.  
  84. //var dataToSend = 'username='+$("input[name^='username']").val()+'&password='+$("input[name^='password']").val();
  85. var url = 'index.php';
  86.  
  87. $.ajax({
  88. type: "POST",
  89. url: url,
  90. data: $( "#loginForm" ).serialize(),
  91. success: function(response){
  92. alert(response);
  93. if (data == "success") {
  94. window.location = 'dashboard.php';
  95. }
  96. else{
  97. $("#isa_warning").html(response);
  98. }
  99. }
  100.  
  101. });
  102. event.preventDefault();
  103.  
  104. });
  105.  
  106. </script>
  107.  
  108. <script>
  109. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  110. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  111. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  112. })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  113.  
  114. ga('create', 'UA-55238160-10', 'auto');
  115. ga('send', 'pageview');
  116.  
  117. </script>
  118.  
  119. <?php
  120. include("common/menu.php");
  121. ?>
  122.  
  123. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  124. <html xmlns="http://www.w3.org/1999/xhtml">
  125. <head>
  126. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  127. <title>::: My Homework :::</title>
  128. <meta name="description" content="We engage in high quality writing of essays, term papers, research papers, thesis papers, dissertations, book reviews, book reports, speeches, assignments, business papers and web content. We are a real-time freelancing service out to efficiently deliver work. We provide high-quality papers written from scratch to our customers to suit their needs whenever, wherever; papers are plagiarism free, and on time.">
  129. <meta name="keywords" content="writing, essays, term papers, research papers, business papers, speeches, plagirism free">
  130. <meta name="robots" content="index, nofollow">
  131. <meta name="web_author" content="samuel, shammir">
  132. <meta name="language" content="english">
  133. <!--
  134. Template 2033 Business
  135. http://www.tooplate.com/view/2033-business
  136. -->
  137. <!-- Global site tag (gtag.js) - Google Analytics -->
  138. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-107952008-1"></script>
  139. <script>
  140. window.dataLayer = window.dataLayer || [];
  141. function gtag(){dataLayer.push(arguments);}
  142. gtag('js', new Date());
  143.  
  144. gtag('config', 'UA-107952008-1');
  145. </script>
Add Comment
Please, Sign In to add comment