<?php
//routes/frontend/login.php

$f3->route('GET /login', function($f3){
    if($f3->get('SESSION.userID')){
        $f3->reroute('/backend/post');
    }else{
        require('controllers/frontend/login/get.php');
        get($f3);
    }
        
});

$f3->route('POST /login', function($f3){
    require('controllers/frontend/login/checkUser.php');
    checkUser($f3);
});

$f3->route('GET /backend/logout', function($f3){
    if($f3->get('SESSION.userID')){
        $f3->clear('SESSION');
        $f3->reroute('/');
    }else{
        $f3->reroute('/login');
    }
});

 

<!--views/backend/post.html-->

<html>
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <title><?php echo $appName." - ".$pageTitle; ?></title>
        <script src="<?php echo $BASE ?>/public/scripts/jQuery.js"></script>
        <link href="<?php echo $BASE ?>/public/fonts/setup.css" rel="stylesheet" ></link>
        <link href="<?php echo $BASE ?>/public/images/site_logo.png" rel="icon" ></link>
        <link href="<?php echo $BASE ?>/public/styles/global.css" rel="stylesheet"></link>
        <link href="<?php echo $BASE ?>/public/styles/backend/partials/header.css" rel="stylesheet"></link>
    </head>
    <body>
        <section class='Header'>
            <div class='wrapper region'>
                <div class='logo'><?php echo $pageTitle ?></div>

                <form action='/backend/search' method='post'>
                    <select name="select" class='select'>
                        <option>ការផ្សាយ</option>
                        <option>ជំពូក</option>
                        <option>ទំព័រស្តាទិក</option>
                        <option>សៀវភៅ</option>
                        <option>អ្នក​និពន្ធ</option>
                    </select>
                    
                    <input type='text' name='search' placeholder="Search" required />
                    <input type='submit' value='ស្វែង​រក'​​ />
                </form>

                <div class='logout'><a href='<?php echo $BASE ?>/'>ទំព័រមុខ</a> | <a href='<?php echo $BASE ?>/backend/logout'>ចេញ​ក្រៅ</a></div>
            </div>
        </section>

 

/* public/styles/backend/partials/header.css */
.Header{
    background: var(--background-dark);
}

.Header .wrapper{
    display: grid;
    grid-template-columns: 25% auto 25%;
    align-items: center;
    padding: 5px 0;
}

.Header .wrapper .logo{
    font: 28px/1.5 StardosStencil, Limonf3;
}

.Header .wrapper form{
    display: grid;
    grid-template-columns: 15% auto 15%;
}

.Header .wrapper form select,
.Header .wrapper form input{
    font: var(--body-font);
}

.Header .wrapper form input{
    padding: 0 10px;
}

.Header .wrapper .logout{
    text-align: right;
}

.Header .wrapper .logout a{
    color: white;
    font-size: 16px;
}

 

https://github.com/Sokhavuth/PHP-REST-API

http://khmerweb.epizy.com/media/