I am writing a PHP file but I don't know what is the best way to create a link while the link is in the same file but with a different ID. What I mean is that I have a file named test.php
and it contains something like:
if ($id == "") {
echo "<a href='".$_SERVER['PHP_SELF']."?id=test'>Try the test page</a>";
} else if ($id == "test") {
echo "Here is the testing content with various information!";
}
I want to know what is better for more secure code:
$_SERVER['PHP_SELF']?id=test
or test.php?id=test
.
I know it serves the same purpose now, but if I change the file name $_SERVER['PHP_SELF']?id=test
seems better because it will still point to the same file.
But I would like to know for sure which is safer.