Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####index####
- <?php
- require_once "../include/autoload.php";
- get_template('head'); ?>
- <?php $s = filter_input(INPUT_GET, 's', FILTER_SANITIZE_STRING); ?>
- <?php $a = filter_input(INPUT_GET, 'action', FILTER_SANITIZE_STRING); ?>
- <?php
- // Start the session
- // Defines username and password. Retrieve however you like,
- $username = "admin";
- $password = "admin";
- // Error message
- $error = "Error";
- // Checks to see if the user is already logged in. If so, refirect to correct page.
- if (isset($_SESSION['loggedIn']) && $_SESSION['loggedIn'] == true) {
- $error = "success";
- header('Location: success.php');
- }
- // Checks to see if the username and password have been entered.
- // If so and are equal to the username and password defined above, log them in.
- if (isset($_POST['username']) && isset($_POST['password'])) {
- if ($_POST['username'] == $username && $_POST['password'] == $password) {
- $_SESSION['loggedIn'] = true;
- header('Location: success.php');
- } else {
- $_SESSION['loggedIn'] = false;
- $error = "Invalid username and password!";
- }
- }
- ?>
- <div class="container">
- <h1>Adminileht</h1>
- <html>
- <head>
- <title>Login Page</title>
- </head>
- <body>
- <!-- Output error message if any -->
- <?php echo $error; ?>
- <!-- form for login -->
- <form method="post" action="index.php">
- <label for="username">Username:</label><br/>
- <input type="text" name="username" id="username"><br/>
- <label for="password">Password:</label><br/>
- <input type="password" name="password" id="password"><br/>
- <input type="submit" value="Log In!">
- </form>
- </body>
- </html>
- </div>
- <?php get_template('footer');
- #####LOGIN#####
- <?php
- session_start();
- if(isSet($_POST['login'])) {
- include('db.php');
- $username = mysql_real_escape_string($_POST['username']);
- $password = sha1($_POST['password'] );
- $query = mysql_query("SELECT * FROM tab WHERE username='".addSlashes($username)."' AND password='".addSlashes($password)."'");
- $res = mysql_num_rows($query);
- if ($res == 1) {
- $_SESSION['username'] = $username;
- $_SESSION['password'] = $password;
- $_SESSION['userobj'] = mysql_fetch_assoc($query);
- header('Location: http://localhost/member_area.php');
- exit;
- } else {
- echo 'Data does not match <br /> RE-Enter Username and Password';
- }
- } else {
- ?>
- <html>
- <head><link rel="stylesheet" type="text/css" href="css.css"></head>
- <body>
- <div id="div1">
- <a href="index.php" id="home">Home</a>
- <a href="Login.php" id="login2">Login</a>
- <a href="register.php" id="register">Register</a>
- </div>
- <table width="200" border="0" cellspacing="1" align="center">
- <form id="form1" method="post" action="login.php">
- <tr>
- <td colspan="2"><h2>Members login</h2></td>
- </tr>
- <tr>
- <td>Username: </td>
- <td>
- <input type="text" name="username" id="username"/>
- </td>
- </tr>
- <tr>
- <td>Password: </td>
- <td><input type="password" name="password" id="password"/> </td>
- </tr>
- <tr>
- <td colspan="2" align="center">
- <input type="submit" name="login" id="login" value="login" />
- </td>
- </tr>
- </form>
- </table>
- </body>
- </html>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement