I have a page called Error.php. Variables are usually passed to it using the query string so that it will display the corresponding message to the error code I have assigned.
Example: Error.php?id=1
Here is the section of my page below:
<?php
if($_GET["id"] == "0")
{
echo "Display certain information...";
}
elseif($_GET["id"] == "1")
{
echo "Display certain information...";
}
elseif($_GET["id"] == "2")
{
echo "Display certain information...";
}
elseif($_GET["id"] == "3")
{
echo "Display certain information...";
}
else
{
echo "Display certain information...";
}
?>
All the information works fine, but the only problem is, if there is no query string (leaving it as just "Error.php"), it displays errors saying "Undefined index: id in.....". Is there a way to make Error.php unaccessible unless there is a query string? I'm sorry if my code grammer is incorrect, I'm very new to PHP. Thank you.