Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Login.php
- include("../include/config.php");
- if(isset($_POST['login'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $pswd = sha1($password);
- $timeupdate = date('H:i:s Y-m-d');
- $ip = $_SERVER['REMOTE_ADDR'];
- $query = "SELECT * FROM admin_login WHERE user = '".$username."' AND pswd = '".$pswd."' ";
- $qstatement = $pdo->prepare($query);
- $qstatement->execute(array($username, $password));
- if($qstatement->rowCount() == 1){
- $_SESSION['username'] = $username;
- $loginupdate = "UPDATE admin_login SET login_status = ? , IP = ? WHERE user = ?";
- $updatestmnt = $pdo->prepare($loginupdate);
- $updatestmnt->execute(array($timeupdate, $ip, $username));
- }
- if(@$_SESSION['username']):
- if(headers_sent()):?>
- <meta http-equiv='Refresh' content="1; url=dashboard.php"/>
- <?php
- else:
- header('Location: dashboard.php');
- endif;
- else:
- echo 'wrong username/password';
- endif;
- }
- ?>
- //home.php
- <?php
- include ("../include/config.php");
- session_start();
- if($_SESSION['username'])){
- ?>
- <html>
- <head>
- <title>home</title>
- </head>
- <body>
- <h3>Dashboard</h3>
- <hr>
- <h2>
- <?php
- echo "WelCome : " .$_SESSION['username'];
- ?>
- </h2>
- <h2><a href="index.php?logout">Logout</a> </h2>
- </body>
- </html>
- <?php
- }
- else
- echo "kindly login to continue";
- ?>
- //logout.php
- <?php
- session_start();
- session_destroy();
- unset($_SESSION['username']);
- header("location:login.php")
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement