function redirectTo ($message, $location = NULL, $second = NULL) {
$second = ($second != NULL) ? $second : 2;
if ($location != NULL) {
if ($location == 'back') {
$location = $_SERVER['HTTP_REFERER'];
} else {
$location = $location . '.php';
if (file_exists($location)) {
$location = $location;
} else {
$second = 5;
$message = '<div class="alert alert-danger">Error : '. $location . ' Not Exist!, You Will Be Redirected To Home Page After ' . $second . ' Seconds.</div>';
$location = 'index.php';
}
}
} else {
$location = 'index.php';
}
echo $message;
echo '<div class="alert alert-info"><span class="glyphicon glyphicon-refresh icon" aria-hidden="true"></span> You Will Be Redirected After ' . $second . ' Seconds.</div>';
header("refresh:$second;$location");
exit;
}