I have the following code that its function would be to detect the entry from the page step1.php to paso2.php
Let me explain, I want people who enter step2.php without going through the first step not to be allowed, with this code I have achieved it but I have a problem that is that it does not detect that I am entering from step1.php and I enter from any other page with a link to step2.php and log in normally when I should also send the error message
<?php
$ref = $_SERVER['HTTP_REFERER'];
if(isset($ref[0])) {
$protocol = strtolower(parse_url($ref)['scheme']) === 'https' ? 'https':'http';
echo (strtolower($ref) === $protocol . '://paso1.php') ? 'welcome':'BIENVENIDO, EXITO';
} else {
echo 'ERROR HAS INGRESADO POR URL O NO HAS INGRESADO DESDE PASO1.PHP';
}
?>
I would like the browser to act in this way: (1) if you enter by step1.php IF I allow you to enter (2) If you enter by URL I do NOT allow you to enter (3) If you enter a link from another page other than step1.php I DO NOT allow you to enter.
/// everything works except the (3)