I would like to detect how a user accesses a page with php. For example, if I have this form on an html page:
<form action="php/file.php" method="post">
<input type="text" name="text">
<input type="submit">
</form>
and I send it to file.php:
<?php
echo $_POST["text"];
?>
It should work as normal, but if I went to file.php directly, (something like example.com/php/file.php) I would like it to display something like the 404 error page.
Is there any way to do this? Thanks!