Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- #Brings in a system where where the login errors are recoded into a seperate document called "errorlog.txt"
- include_once("connection2/conn2.php");
- $user = $_POST["username"];
- $pass = $_POST["password"];
- $validated = false;
- session_start();
- $_SESSION['Login'] = "";
- if($user!=""&& $pass!="")
- {
- $sql = "SELECT * FROM BTEC_User WHERE LoginName = '$user' AND Password = '$pass'";
- echo "ass" && $sql;
- $rs = mysql_query($sql, $conn2);
- $result = mysql_num_rows($rs);
- ##/ Basic Sql injection detergent
- if ($result > 0) $validated = true;
- if ($validated) {
- $_SESSION['login'] = "OK";
- $_SESSION['username'] = $user;
- $_SESSION['password'] = $pass;
- if($user=='Admin')
- $_SESSION['admin']=true;
- else
- $_SESSION['admin']=false;
- $ip = $_SERVER["REMOTE_ADDR"];
- $browser = $_SERVER['HTTP_USER_AGENT'];
- //echo "ip=$ip;";
- $date = date("d-m-y H:i:s");
- $file = "login.txt";
- // Open the file to get existing content
- $current = file_get_contents($file);
- // Appending a new person to the file
- $current .="$user logged in from IP Address of $ip on $date using Browser and OS:$browser "."\r\n";
- // Write the contents back to the file
- file_put_contents($file, $current);
- header('Location:Grades_Menu.php');
- } else {
- $_SESSION['login'] = "";
- echo "Invalid username or password.";
- trigger_error("invalid username or password");
- }
- }
- else $_SESSION['login'] = "";
- ?>
- <html>
- <title>Login Page</title>
- <head>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <style>
- /* Used for responsive design */
- * {
- box-sizing: border-box;
- }
- /* logo, Size/Position */
- img {
- float: right;
- position: relative;
- width: 30%;
- height: auto;
- background-image: url('img_PenLogo.png');
- background-repeat: no-repeat;
- background-size: contain;
- border: 1px solid red;
- }
- .row:after {
- content: "";
- clear: both;
- display: table;
- }
- /* Sets the class of the grid columns for responsive design */
- [class*="col-"] {
- float: left;
- padding: 15px;
- width: 100%;
- }
- /* Sets columns for responsive design / Phone, Tablet Devices */
- @media only screen and (min-width: 600px) {
- .col-s-1 {width: 8.33%;}
- .col-s-2 {width: 16.66%;}
- .col-s-3 {width: 25%;}
- .col-s-4 {width: 33.33%;}
- .col-s-5 {width: 41.66%;}
- .col-s-6 {width: 50%;}
- .col-s-7 {width: 58.33%;}
- .col-s-8 {width: 66.66%;}
- .col-s-9 {width: 75%;}
- .col-s-10 {width: 83.33%;}
- .col-s-11 {width: 91.66%;}
- .col-s-12 {width: 100%;}
- }
- /* Sets columns for responsive design / Desktop */
- @media only screen and (min-width: 768px) {
- .col-1 {width: 8.33%;}
- .col-2 {width: 16.66%;}
- .col-3 {width: 25%;}
- .col-4 {width: 33.33%;}
- .col-5 {width: 41.66%;}
- .col-6 {width: 50%;}
- .col-7 {width: 58.33%;}
- .col-8 {width: 66.66%;}
- .col-9 {width: 75%;}
- .col-10 {width: 83.33%;}
- .col-11 {width: 91.66%;}
- .col-12 {width: 100%;}
- }
- html {
- font-family: "Lucida Sans", sans-serif;
- }
- /* Sets the design options of the on screen title */
- .header {
- background-color: #ff944d;
- color:#ffffff;
- padding: 15px;
- border: solid;
- border-color: #771d81;
- }
- /* Sets list type for buttons */
- .buttons ul {
- list-style-type: none;
- margin: 0;
- padding: 0;
- }
- /* Sets size/position/colour of buttons*/
- .buttons li {
- float: left;
- list-style: none;
- text-align: center;
- padding: 8px;
- margin-bottom: 7px;
- background-color: #ff944d;
- color: #333333;
- width: 60%;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
- }
- /* Sets Highlight colour*/
- .buttons li:hover {
- background-color: #ff6666
- ;
- }
- /* Sets button text to white*/
- .buttons li a{
- color: #ffffff
- }
- /* Unused*/
- .aside {
- background-color: #33b5e5;
- padding: 15px;
- color: #ffffff;
- text-align: center;
- font-size: 14px;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
- }
- /* Sets the footer look and position */
- .footer {
- background-color: #0099cc;
- color: #ffffff;
- text-align: center;
- font-size: 12px;
- padding: 15px;
- }
- .button{
- float: left;
- list-style: none;
- text-align: center;
- padding: 8px;
- margin-bottom: 7px;
- background-color: #ff944d;
- color: #333333;
- width: 60%;
- box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
- }
- .row{
- background-color: #33b5e5;
- }
- </style>
- </head>
- <body>
- <div class="header">
- <h1>Btec Grades</h1>
- </div>
- <!--Script functions for colour options, day and night mode-->
- <script>
- function colorbtn(color) {
- document.getElementById("row").style.backgroundColor = color;
- }
- function nightmode(){
- document.body.style.background="#262626"
- }
- function daymode(){
- document.body.style.background="#ffffff"
- }
- </script>
- <!--Buttons for colour changing, night mode and day mode-->
- <button type="button" onclick="colorbtn('#73E760')">Green</button>
- <button type="button" onclick="colorbtn('#33b5e5')">Blue</button>
- <button type="button" onclick="colorbtn('#FB4E4E')">Red</button>
- <button type="button" onclick="colorbtn('#dd99ff')">Pink</button>
- <button type="button" onclick="nightmode()">Night Mode</button>
- <button type="button" onclick="daymode()">Day Mode</button>
- <div id="row" class="row">
- <form action="Grades_Login.php"
- method="post">
- <table>
- <tr>
- <td
- align="left">Username: </td>
- <td><input
- size=\"20\" type="text"
- size="20" maxlength="15"
- name="username"></td>
- </tr>
- <tr>
- <td
- align="left">Password: </td>
- <td><input
- size=\"20\" type="password"
- size="20" maxlength="15"
- name="password"></td>
- </tr>
- <tr>
- <td> </td>
- <td colspan="2"
- align="left"><input
- type="submit"
- value="Login"></td>
- </tr>
- </table>
- </form>
- <div class="col-6 col-s-9">
- <h1>Welcome to BTEC Grades</h1>
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam pellentesque justo ac semper volutpat. Quisque venenatis nunc massa.</p>
- <img src="img_PenLogo.png"alt="penlogo">
- </div>
- </div>
- <div class="footer">
- <p>BTEC GRADES Copyright / 2014-2017.</p>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement