Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require '../inc/connection.php';
- if(isset($_SESSION['logged_in'])){
- //echo "Dashboard";
- include 'templates/header.php';
- ?>
- <div class="list-group">
- <div class="list-group-item">
- <a class="list-group-item" href="add.php">
- <h4 class="list-group-item-heading">Add Post or Article</h4>
- <p class="list-group-item-text">
- Create New post or article to your CMS blog system with pdo way</p>
- </a>
- <a class="list-group-item" href="delete.php">
- <h4 class="list-group-item-heading"> Delete Post or Article</h4>
- <p class="list-group-item-text"> Delete Old post or article from your CMS blog system with pdo way </p>
- </a>
- <a class="list-group-item active" href="logout.php">
- <h4 class="list-group-item-heading"> Logout</h4>
- <p class="list-group-item-text"> Logout and go have some fun</p>
- </a>
- </div>
- </div> <!-- End list-group -->
- <?php
- include 'templates/footer.php';
- }else{
- if(isset($_POST['username'], $_POST['password'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- if(empty($username) or empty($password)){
- $error = 'Username or Password Empty';
- }else{
- $query = $pdo->prepare("SELECT * FROM `users` WHERE username=? AND password=? ");
- $query->bindValue(1, $username);
- $query->bindValue(2, $password);
- $query->execute();
- $num = $query->rowCount();
- if($num == 1){
- $_SESSION['logged_in'] = true;
- header('Location: index.php');
- exit();
- }else{
- $error = 'Wrong Username or Password';
- }
- }//else
- }
- include 'templates/header.php';
- if(isset($error))
- echo "<p class='bg-danger btn-lg'> $error </p>";
- ?>
- <form action="index.php" method="post" rol="form">
- <div class="form-group">
- <label for="">Username : </label>
- <input class="form-control" name="username" placeholder="username" type="text">
- </div>
- <div class="form-group">
- <label for="">Password : </label>
- <input class="form-control" name="password" placeholder="password" type="password">
- </div>
- <input class="btn btn-info btn-lg btn-block" value="Login" type="submit">
- </form>
- <?php
- include 'templates/footer.php';
- ?>
- <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement