Answers for "middleware php"

PHP
0

middleware php

<?php
//index.php at the beginin of the page
require_once('./Controller/yourController.php');

//if url have argument
if (isset($_GET['action'])) {
    switch ($_GET['action']) {
        case 'x':
            if (!empty($_POST)) {
                //call Post method
            } else {
                //Send to x page
            }
            break;

        case 'y':
            //call y function
            break;
    }
} else {
  	//Call when no parameters in the url
    //if want to use login session 
  	//$user_id = $_SESSION['user_id'] ?? false;
		
    if ($user_id) {
        //Succes Connection
    } else {
        //Send to login page
    }
}
Posted by: Guest on July-22-2021

Browse Popular Code Answers by Language