Jump to content

[SOLVED] Best way to do this?


Dane

Recommended Posts

Hey guys.

 

I want an option on my website were if i goto my admin control pannel and say set `website_online` ONLINE or OFFLINE

 

Would the best way to show my website being online or offline be to put something like this at the top of the page?

 

<?php

 

session_start();

 

SELECT FROM blah WHERE `website_online` =  blah

 

if $website_online == 'OFFLINE'

 

echo 'dont show'

 

else {

 

rest of page here

 

}

 

 

Is there a better way of doing this?

 

Thanks

 

Dane

Link to comment
Share on other sites

Thats about the only way of doing it. Of course, if you want to show the error message on any page when the website is offline, then you'd be better off storing this:

 

<?php
//connect to datase
$sql = "SELECT `website_online` FROM `yourtable`";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_row($result);
if($row[0] == 'OFFLINE'){
echo 'Website is currently offline';
exit;//stop running the rest of the script
}
?>

 

In a file, and requiring it in every page.

Link to comment
Share on other sites

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.