I know that $_SERVER["HTTP_REFERER"] can be easily faked through setting your host file on your computer. What is a better alternative?
I want a form to be submitted to itself, e.g.
formProcess.php
<?php
if(isset($_POST["formButton"]))
{
doThis($_POST["formField1"], $_POST["formField2"]);
}
?>
<html>
<body>
<form action="" method="POST">
<input name="formField1">
<input name="formField2">
</form>
</body>
</html>
I read somewhere that setting a session can be used as an alternative. Is this the right way to go?
<?php
session_start();
if(!isset($_POST["submit"]))
{
$_SESSION["on_the_right_page"] = TRUE;
}
if(isset($_POST["submit"]))
{
if($_SESSION["on_the_right_page"] == TRUE)
{
doThis($_POST["formField1"], $_POST["formField2"]);
}
}
?>
<html>
<body>
<form action="" method="POST">
<input name="formField1">
<input name="formField2">
</form>
</body>
</html>
Is that the best way to make sure that's right? Or can a user fake a $_SESSION too?