Jump to content

how to change page apperance (mode) using php - maintenance mode


eleven0

Recommended Posts


	<?php $status = $_GET["status"];
	if (!$status) {
	echo("this is when everything is working fine");
	}

	else if($status=="1")       {echo("This is status 1, it will set to '1' when page is under construction."); }

	else { echo "<b><h1>404 Error</h1></b>"; } 

	?>

 

 

I'm trying to create a control panel for my website. I want to configure couple of modes for certain pages. For instance, lets say that a web page is under construction, I'd be setting the status to 1, which shows my maintenance mode message.

 

But the code I have requires my users to type "?status=1" in the URL to see the message, which is useless. Maybe i can redirect them to "?status=1"?

 

is it possible to control this through a control panel? if so, how?

 

Edit:

This is probably not a good way of doing what I want. Because, users can type "status=0" to see the page even though status 1 is set. Any ideas?

 

 

 

use a header function if need be where the echo is....

<?php 

$status=1; // set this for the current website status.........


switch ($status){

CASE "1":

	echo"where under construction";

break;

CASE "2":

	echo"mail server down";

	break;
}
?>

Yes, you are correct this is a poor method!

You could create an array of all your site files and the status value within a file included on every page. Test the value against the server gloabal PHP_SELF

 

$pageStats['/index.php']  = 0;
$pageStats['/page1.php'] = 1;
$pageStats['/page2.php'] = 0;

$status = $pageStats[$_SERVER['PHP_SELF']];
if($status == 1) {
// redirect to under construction page
header("Location:construction-page.php");
exit();
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.