Run file safely

0

From my code in PHP I want to run another PHP file. For this I use this line:

    header('Location: proceso.php');
    exit;

How can I run this file in such a way that it is more secure and only executes from this line of code?

    
asked by Piropeator 22.06.2018 в 22:05
source

1 answer

1

Hello, you could use something like this at the beginning of your file, process.php, we should know if that process you send to call from a submit or button, or just want to include its functionality in your php page here you would use include or require_once.

//si tu llamado a este proceso viene de un POST
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
      Lo que quieres que se ejecute
} else {
      //Redirecciona si quieres entrar por URL
      header('Location: proceso.php');
      exit;
}

Greetings!

    
answered by 23.06.2018 / 00:07
source