Ok - this is my first tuthope you like it the projects name is "ProWebMaintenance" after http://www.prowebdesigns.co.uk/
OK open up your index.php file of your website if you have a .htm/.html or any other extension please change it to .php
Ok right at the very top even above stating your document C+P this:
Please if you want to know how it works read the commentsPHP Code:<?php // this starts PHP coding. a bit like <html>
error_reporting(0) // this turns off error_reporting for stuff like notices
$host = "*usually localhost*"; // this is your host
$user = "*username*"; // your username
$db ="*yourDB*"; // your database
$pass = "*password*"; // your password
mysql_connect($host, $user, $pass); // connect function with your vars
mysql_select_db($db); // selecting your database
$query = 'SELECT status FROM `status`'; // this is your SQL query
$result=mysql_query($query); // this makes the SQL query
$status = mysql_fetch_assoc($result); // this makes sense of the results.
if($status[status] == "offline") die("This website is under maintenance, please check back later"); // this is asking if the status is equal to 'offline' then kill the rest of the script and display an error message
?> // closes php with the closing tag
OK heres what you need to inject into your SQL:
Rather self-explanatory as things mean what they are - eg insert inserts, select selects, create table if not exists creates a table if it doesn't exist, etc...Code:CREATE TABLE IF NOT EXISTS `status` ( `status` text ) ENGINE=MyISAM DEFAULT CHARSET=utf8; -- -- Dumping data for table `status` -- INSERT INTO `status` (`status`) VALUES ('online');
OK now - we want somewhere where we can turn the site on and offline - i myself am quite new to php, so i embedded this into a pre-built user system, i advise you to do the same unless you want people turning your site on and ofso this is the page i made:
updatestatus.html
lets look over this code, we first open a form tag and then we choose the action updated.php , the inputs name is ud_status for future reference.HTML Code:<form method="post" action="updated.php"> Status changer: Status: (Choose offline or online)<input type="text" name="ud_status"> </form>
now
updated.php
once more please read the comments in order to understand the coding.PHP Code:<?php // opens php
$ud_status=$_POST['ud_status']; // gets the inputted text
$host = "*host*"; // your host
$user = "*username*"; // your username
$db = "*yourDB*"; // your db
$pass = "*pass*"; // your password
mysql_connect($host, $user, $pass); // connects to mysql
mysql_select_db($db); // selects the db
$query="UPDATE status SET status = '$ud_status'"; // the query to update the field to a new text.
mysql_query($query); // queries mysql
echo "Record Updated"; // confirmation of updating
mysql_close(); // closes mysql.
?> // closes php
Last thing - when the site is online you can use this code within your html code using a .php extension to display that the site is online.
Hope you enjoyed the tutorialPHP Code:<span class="sidetext">Site is <font color="#00FF00"><b><i>
<?php
echo "$status[status]";
?>
</font></span>
- Charlie![]()





hope you like it the projects name is "ProWebMaintenance" after 
so this is the page i made:
lol.
Reply With Quote







