adamjones Posted September 21, 2008 Share Posted September 21, 2008 Hi, I was wondering anyone could help make a maintenance script, or give a ink to one. Basically, i want to add something like; <? if(! maintenance == 1} header("location:maintenance.php"); } ?> To the top of my pages, and I would like to turn maintenance on or off, through an external file. Therefore, if it's set to 1, then it would redirect the user to maintenance.php, and if its set to anything else, it wouldn't redirect. If that makes sense? Any help on this would be great! Cheers. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 21, 2008 Share Posted September 21, 2008 there are many ways of doing this... but yes, the most simple way would be to add if(MAINTENANCE == true) { header('location:maintenance.php'); die(); } to the top of every page or to a bootstrap file and then have somewhere above that, also likely on a bootstrap file... define('MAINTENANCE', true); // or false you can manually change. of course most requirements for maintenance are much more complicated than that, but it's a good starting point. Quote Link to comment Share on other sites More sharing options...
adamjones Posted September 21, 2008 Author Share Posted September 21, 2008 Ok. I see. So if I add; <? @include check.php if(MAINTENANCE == true) { header('location:maintenance.php'); die(); } ?> And then make a file called check.php, what would I add to the check.php file to set it to true/false? Cheers. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 21, 2008 Share Posted September 21, 2008 define('MAINTENANCE', true); Also, don't use short tags, don't use @, and put quotes around check.php. Quote Link to comment Share on other sites More sharing options...
adamjones Posted September 21, 2008 Author Share Posted September 21, 2008 Thank's generic, all working now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.