Jump to content

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


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();
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.