Upon detecting an error, my code redirects the user to another page which logs the data, sends an email to the administrator, and alerts the user of the error.
The user's data is stored using $_SESSION variables. In order to log the error, I pass the error number in the URL to the required file (in a different folder). However, in order for "require" to work properly when passing variables, the full URL to the required page must be entered. So here's what it looks like:
page1.php
Code: Select all
session_start();
$errorPath = "http://".$_SERVER['SERVER_NAME'].dirname(dirname($_SERVER['PHP_SELF']))."/Folder/errorLogScript.php";
echo $_SESSION['userID'];
...
if ($foo !='bar'){
require $errorPath.'?errorRef=0023';
die();
}session_start();
Code: Select all
if (isset($_SESSION['userID'])){
echo "session valid";
} else {
echo "session data lost";
}Page1.php will display the userID but errorLogScript.php will display
Code: Select all
session data lostThanks,
Josh