Check how user accessed file/script?
Posted: Sat Nov 28, 2009 5:59 pm
Is there a way in PHP to check how a user accessed a PHP file?
For example, say a web user types in (directly visits) http://host.domain/embeddedmailingscript.php rather than accessing the PHP through a form (e.g. POST to embeddedmailingscript.php). Is it possible to block the former whilst still allowing the latter?
What i'm trying to achieve (in pseudo-pseudocode):
Thanks in advance for any help/tips/pointers 
For example, say a web user types in (directly visits) http://host.domain/embeddedmailingscript.php rather than accessing the PHP through a form (e.g. POST to embeddedmailingscript.php). Is it possible to block the former whilst still allowing the latter?
What i'm trying to achieve (in pseudo-pseudocode):
Code: Select all
<?php
if ($userDirectlyVisits == true)
{
header("Location: home.php"); //user returned to default homepage
}
else
{
// Code completed as normal e.g. $_POST[] input taken and manipulated
}
?>