Advertisement
Guest User

Loginpage

a guest
May 26th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.61 KB | None | 0 0
  1. <?php
  2.  
  3. #Brings in a system where where the login errors are recoded into a seperate document called "errorlog.txt"
  4. include_once("connection2/conn2.php");
  5.  
  6. $user = $_POST["username"];
  7. $pass = $_POST["password"];
  8. $validated = false;
  9.  
  10.  
  11. session_start();
  12. $_SESSION['Login'] = "";
  13. if($user!=""&& $pass!="")
  14.  
  15. {
  16. $sql = "SELECT * FROM BTEC_User WHERE LoginName = '$user' AND Password = '$pass'";
  17. echo "ass" && $sql;
  18. $rs = mysql_query($sql, $conn2);
  19. $result = mysql_num_rows($rs);
  20.  
  21. ##/ Basic Sql injection detergent
  22.  
  23. if ($result > 0) $validated = true;
  24. if ($validated) {
  25. $_SESSION['login'] = "OK";
  26. $_SESSION['username'] = $user;
  27. $_SESSION['password'] = $pass;
  28. if($user=='Admin')
  29. $_SESSION['admin']=true;
  30. else
  31. $_SESSION['admin']=false;
  32.  
  33. $ip = $_SERVER["REMOTE_ADDR"];
  34. $browser = $_SERVER['HTTP_USER_AGENT'];
  35. //echo "ip=$ip;";
  36. $date = date("d-m-y H:i:s");
  37. $file = "login.txt";
  38. // Open the file to get existing content
  39. $current = file_get_contents($file);
  40. // Appending a new person to the file
  41. $current .="$user logged in from IP Address of $ip on $date using Browser and OS:$browser "."\r\n";
  42. // Write the contents back to the file
  43. file_put_contents($file, $current);
  44.  
  45.  
  46. header('Location:Grades_Menu.php');
  47. } else {
  48. $_SESSION['login'] = "";
  49. echo "Invalid username or password.";
  50. trigger_error("invalid username or password");
  51. }
  52. }
  53. else $_SESSION['login'] = "";
  54. ?>
  55.  
  56.  
  57. <html>
  58. <title>Login Page</title>
  59. <head>
  60. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  61. <style>
  62. /* Used for responsive design */
  63. * {
  64. box-sizing: border-box;
  65. }
  66. /* logo, Size/Position */
  67. img {
  68. float: right;
  69. position: relative;
  70. width: 30%;
  71. height: auto;
  72. background-image: url('img_PenLogo.png');
  73. background-repeat: no-repeat;
  74. background-size: contain;
  75. border: 1px solid red;
  76.  
  77. }
  78. .row:after {
  79. content: "";
  80. clear: both;
  81. display: table;
  82. }
  83. /* Sets the class of the grid columns for responsive design */
  84. [class*="col-"] {
  85. float: left;
  86. padding: 15px;
  87. width: 100%;
  88. }
  89. /* Sets columns for responsive design / Phone, Tablet Devices */
  90. @media only screen and (min-width: 600px) {
  91. .col-s-1 {width: 8.33%;}
  92. .col-s-2 {width: 16.66%;}
  93. .col-s-3 {width: 25%;}
  94. .col-s-4 {width: 33.33%;}
  95. .col-s-5 {width: 41.66%;}
  96. .col-s-6 {width: 50%;}
  97. .col-s-7 {width: 58.33%;}
  98. .col-s-8 {width: 66.66%;}
  99. .col-s-9 {width: 75%;}
  100. .col-s-10 {width: 83.33%;}
  101. .col-s-11 {width: 91.66%;}
  102. .col-s-12 {width: 100%;}
  103. }
  104. /* Sets columns for responsive design / Desktop */
  105. @media only screen and (min-width: 768px) {
  106. .col-1 {width: 8.33%;}
  107. .col-2 {width: 16.66%;}
  108. .col-3 {width: 25%;}
  109. .col-4 {width: 33.33%;}
  110. .col-5 {width: 41.66%;}
  111. .col-6 {width: 50%;}
  112. .col-7 {width: 58.33%;}
  113. .col-8 {width: 66.66%;}
  114. .col-9 {width: 75%;}
  115. .col-10 {width: 83.33%;}
  116. .col-11 {width: 91.66%;}
  117. .col-12 {width: 100%;}
  118. }
  119. html {
  120. font-family: "Lucida Sans", sans-serif;
  121. }
  122. /* Sets the design options of the on screen title */
  123. .header {
  124. background-color: #ff944d;
  125. color:#ffffff;
  126. padding: 15px;
  127. border: solid;
  128. border-color: #771d81;
  129. }
  130.  
  131.  
  132. /* Sets list type for buttons */
  133. .buttons ul {
  134. list-style-type: none;
  135. margin: 0;
  136. padding: 0;
  137. }
  138. /* Sets size/position/colour of buttons*/
  139. .buttons li {
  140. float: left;
  141. list-style: none;
  142. text-align: center;
  143. padding: 8px;
  144. margin-bottom: 7px;
  145. background-color: #ff944d;
  146. color: #333333;
  147. width: 60%;
  148. box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  149. }
  150. /* Sets Highlight colour*/
  151. .buttons li:hover {
  152. background-color: #ff6666
  153. ;
  154. }
  155. /* Sets button text to white*/
  156. .buttons li a{
  157. color: #ffffff
  158. }
  159. /* Unused*/
  160. .aside {
  161. background-color: #33b5e5;
  162. padding: 15px;
  163. color: #ffffff;
  164. text-align: center;
  165. font-size: 14px;
  166. box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  167. }
  168. /* Sets the footer look and position */
  169. .footer {
  170. background-color: #0099cc;
  171. color: #ffffff;
  172. text-align: center;
  173. font-size: 12px;
  174. padding: 15px;
  175. }
  176.  
  177. .button{
  178. float: left;
  179. list-style: none;
  180. text-align: center;
  181. padding: 8px;
  182. margin-bottom: 7px;
  183. background-color: #ff944d;
  184. color: #333333;
  185. width: 60%;
  186. box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
  187. }
  188.  
  189. .row{
  190. background-color: #33b5e5;
  191. }
  192. </style>
  193. </head>
  194. <body>
  195.  
  196. <div class="header">
  197. <h1>Btec Grades</h1>
  198. </div>
  199.  
  200. <!--Script functions for colour options, day and night mode-->
  201. <script>
  202. function colorbtn(color) {
  203. document.getElementById("row").style.backgroundColor = color;
  204. }
  205. function nightmode(){
  206. document.body.style.background="#262626"
  207. }
  208. function daymode(){
  209. document.body.style.background="#ffffff"
  210. }
  211.  
  212. </script>
  213.  
  214. <!--Buttons for colour changing, night mode and day mode-->
  215. <button type="button" onclick="colorbtn('#73E760')">Green</button>
  216. <button type="button" onclick="colorbtn('#33b5e5')">Blue</button>
  217. <button type="button" onclick="colorbtn('#FB4E4E')">Red</button>
  218. <button type="button" onclick="colorbtn('#dd99ff')">Pink</button>
  219. <button type="button" onclick="nightmode()">Night Mode</button>
  220. <button type="button" onclick="daymode()">Day Mode</button>
  221. <div id="row" class="row">
  222.  
  223.  
  224. <form action="Grades_Login.php"
  225. method="post">
  226. <table>
  227. <tr>
  228. <td
  229. align="left">Username: </td>
  230. <td><input
  231. size=\"20\" type="text"
  232. size="20" maxlength="15"
  233. name="username"></td>
  234. </tr>
  235.  
  236. <tr>
  237. <td
  238. align="left">Password: </td>
  239. <td><input
  240. size=\"20\" type="password"
  241. size="20" maxlength="15"
  242. name="password"></td>
  243. </tr>
  244. <tr>
  245. <td> </td>
  246. <td colspan="2"
  247. align="left"><input
  248. type="submit"
  249. value="Login"></td>
  250. </tr>
  251. </table>
  252. </form>
  253.  
  254. <div class="col-6 col-s-9">
  255. <h1>Welcome to BTEC Grades</h1>
  256. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pellentesque justo ac semper volutpat. Quisque venenatis nunc massa.</p>
  257. <img src="img_PenLogo.png"alt="penlogo">
  258. </div>
  259.  
  260. </div>
  261. <div class="footer">
  262. <p>BTEC GRADES Copyright / 2014-2017.</p>
  263. </div>
  264.  
  265.  
  266.  
  267. </body>
  268. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement