Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Having issues with a log in page using PHP
- <Doctype HTML>
- <html>
- <head>
- <?php
- //include the required functions
- include(' ./includes/functions.php');
- //make connection
- $db = conn();
- //check for username and password
- if(isset($_POST['username']) && isset($_POST['password'])) {
- //Query the db for the user
- $result = $db->query("SELECT * FROM users WHERE username ='{$_POST['username']}'");
- //fetch the result set
- $row = $result->fetch_assoc();
- //check credentials again the database
- if ($result == true && md5($_POST['password']) == $row['password']){
- //store user as seesion variable
- $_SESSION['valid_user'] = $_POST['username'];
- /*
- * @Locations:
- * /admin, /calc, /live
- *
- * @Authorization Levels
- * 1 = production employee
- * 2 = Quality tech
- * 3 = Management
- * 0 = not authorized
- *
- * @var = $row['active']
- */
- if ($row['active'] == '3') {
- header('Location: ./admin/index.php ');
- }
- elseif ($row['active'] == 2) {
- header('Location: ./calc/index.php ');
- }
- elseif ($row['active'] == 1) {
- header('Location: ./live/data.php ');
- }
- }
- elseif ($_POST['password'] != $row['password']) {
- echo ('Password Incorrect');
- }
- }
- else
- {
- ?>
- <style type="text/css">
- body
- {
- margin: 0;
- /* IE10 */
- background-image: -ms-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
- background-repeat: no-repeat;
- /* Mozilla Firefox */
- background-image: -moz-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
- background-repeat: no-repeat;
- /* Opera */
- background-image: -o-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
- /* Webkit (Safari/Chrome 10) */
- background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #FFFFFF), color-stop(1, #7EBC50));
- /* Webkit (Chrome 11+) */
- background-image: -webkit-linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
- /* Proposed W3C Markup */
- background-image: linear-gradient(bottom, #FFFFFF 0%, #7EBC50 100%);
- /* IE6-IE9 */
- filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#7EBC50', EndColorStr='#FFFFFF');
- }
- #login
- {
- background-color: #FBFBCA;
- width: 15em;
- margin-right: auto;
- margin-left: auto;
- margin-top: 15%;
- margin-bottom: auto;
- border: 2px solid #3A8E00;
- border-radius: 5px;
- text-align: center;
- padding-bottom: 1em;
- box-shadow: 10px 10px 5px #888888;
- -moz-box-shadow: 10px 10px 5px #888888;
- }
- #login .text, h4
- {
- color: #1C4F00;
- font-family: "Helvetica Neue", "Lucida Grande", "Segoe UI", Arial, Helvetica, Verdana, sans-serif;
- }
- </style>
- <title>LLF Lab || Login Page</title>
- </head>
- <body>
- <div id="login">
- <h4>LLF Lab Login</h4>
- <form action="login.php" method="post">
- <span class="text">Username:</span><br />
- <input type="text" name="username"/><br />
- <br />
- <span class="text">Password:</span><br />
- <input type="password" name="password"/>
- <br />
- <br />
- <input type="checkbox" name="rememberme"/><span class="text">Remember me</span>
- <br />
- <br />
- <input type="submit" value="Login" />
- </form>
- </div>
- </body>
- </html>
- <?php
- }//endif ?>
- <Doctype HTML>
- <html>
- <head>
Add Comment
Please, Sign In to add comment