PDA

View Full Version : [PHP] Maintenance Panel Tutorial



lolwut
01-02-2008, 07:12 PM
If you need to turn your site on and off quickly, then I think I might've helped you out.

This tutorial will teach you how to make a PHP/MySQL site status editor with a login page.

Got moved into Tutorials section after being out for 2 minutes!

Requirements:
- A PHP Server
- A MySQL Database
- A Notepad or FTP Client
- A little HTML knowledge for styling. (Optional)

Note: If you don't understand the code, then read the comments in it, they're there for a reason, to help you!

Step 1:
The Database
Create a new MySQL database, call it whatever you wish but something appropriate like "status" etc would be best.
Keep your database information with you, you will need it in Part 2.
Run the following MySQL query:

CREATE TABLE `sitestatus` (
`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM

INSERT INTO `sitestatus` (
`id` ,
`status` ,
`offmsg` ,
`onpage`
)
VALUES (
'1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://example.com/'
);You have now set up your database.
End of Step 1

Step 2:
The General Configuration
Create a new .php document, call it config.php, in the file, add the following code:

<?php
//================================================== ============================
$host = "localhost"; //Set this to the database host.
$user = "root"; //Set this to the database username.
$pass = ""; //Set this to the database password.
$name = "users"; //Set this to the database name.
$set_password = "12321"; //Set this to the password you want the user to provide before they're given access to the site.
//================================================== ============================
mysql_connect($host,$user,$pass); //Connects to the database.
mysql_select_db($name); //Selects the database.
$info = mysql_query("SELECT * FROM `sitestatus` WHERE `id` = '1' ;"); //Is getting the information we need.
$i = mysql_fetch_object($info); //Is formatting the information we need.
?>Read the comments, then the code will all make sence.
Now, you need to edit the database connection info at the top of the script, you should already know this from when you set up the database in Part 1.
End of Step 2

Step 3:
The Login & Information Editor
Create yet another .php document, this time calling it login.php, in the file, add the following code:

<?php
require("config.php"); //Includes the configuration file we made earlier.
if(!isset($_POST['login'])){ //If they haven't posted the login form...
echo("Please enter the password to edit the site status!<br />
<form method=\"post\">
Password: <input type=\"password\" name=\"password\">
<br />
<input type=\"submit\" value=\"Login\" name=\"login\">
</form>");
//^^ Then show the login form so they can login.
}else{ //If they have posted the login form...
$s_password = $_POST['password']; //Change the password variable to something easier to handle.
if($s_password != $set_password){ //If the supplied password doens't match the set password in the configuration file...
die("You did not enter the correct password!"); //Tell them so, and close the session so they can't edit anything.
} //Ends the if statement (the supplied password didn't match the set one)
setcookie("loggedin","yes"); //Sets a cookie with the users information in, will be used in the next step.
header("Location: edit.php"); //Sends them off to the edit info page.
} //End the if statement (the login from hasn't been posted)
mysql_close(); //Close any remaining MySQL connections.
?>You shouldn't need to edit this code too much.
Now, moving onto the information editor page, create another .php document, this one called edit.php, in the file, add the following code:

<?php
require("config.php"); //Includes the configuration file.
if($_COOKIE[loggedin] == "yes"){ //If they're logged in...
if(!isset($_POST['update'])){ //Check to see if they've posted the form yet.
echo("Please choose the setting to edit here:<br />
<form method=\"post\">
Site Status: <select name=\"status\"><option value=\"on\">On</option><option value=\"off\">Off</option></select>
<br />
Offline Message: <input type=\"text\" name=\"offmsg\" size=\"40\">
<br />
Online Page To Redirect To: <input type=\"text\" name=\"onpage\" size=\"30\">
<br />
<input type=\"submit\" value=\"Update!\" name=\"update\">
</form>");
//^^ Show them the form because they haven't posted it yet.
}else{ //If they have posted the form...
$status = $_POST['status']; //Makes the variable easier to handle.
$offmsg = $_POST['offmsg']; //Makes the variable easier to handle.
$onpage = $_POST['onpage']; //Makes the variable easier to handle.
mysql_query("UPDATE `sitestatus` SET `status` = '" . $status . "', `offmsg` = '" . $offmsg . "', `onpage` = '" . $onpage . "' ;"); //Updates the MySQL database with the information they specified in the form.
echo("The site has been succesfully updated!"); //Tells them that the database has been updated.
setcookie("loggedin","",time() - 3600); //Unsets the logged in cookie.
} //End the if statement (if have(n't) posted the form yet.
}else{ //If they're not logged in...
die("Please login to edit the site status!"); //End the if statement(if they're (not) logged in.
} //End the if statment (if not logged in)
mysql_close(); //Closes any remaining MySQL connections.
?>You shouldn't need to edit this code too much either.
End of Part 3.

Part 4:
The Index page
Create the final .php document, this one called index.php, it will replace the your current index, which you should rename to index2.php so you can make this script redirect to it when you've finished.
On the page, add the following code:

<?php
require("config.php"); //Includes the configuration file we made earlier.
if($i->status == "on"){ //If the site status is set to on...
header($i->onpage); //Then forward the user to the online page.
}elseif($i->status == "off"){ //If the site status is set to off...
echo("The site is currently in offline mode!<br />The reason for this is: <b>" . $i->offmsg . "</b><br />We appologise for any disturbance this may cause.");
//^^ Then tell them so, and show the offline message.
} //Closes the statement.
mysql_close(); //Stops any MySQL connections we had running.
?>You shouldn't need to edit this code much, unless you want to change the phrasing on the offline page.
End of Part 4.

Now you should have completed my tutorial, I hope you have learnt something from it!
If you have any comments to make, then please make them below.

Thanks alot & I hope I've helped,
Edd.

Thread moved to tutorials & Guides by --ss-- (Forum Super Moderator): Excellent tutorial!

Robbie
01-02-2008, 07:21 PM
Very nice, well done!

Hypertext
01-02-2008, 10:46 PM
Better than mine. Alot better. but copy much?

chrisgocrazyH
01-02-2008, 11:45 PM
Warning: Cannot modify header information - headers already sent by (output started at /home/www/simplydj.freehostia.com/preview/config.php:13) in /home/www/simplydj.freehostia.com/preview/login.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/www/simplydj.freehostia.com/preview/config.php:13) in /home/www/simplydj.freehostia.com/preview/login.php on line 17


NONE of the codes work

Caleb
01-02-2008, 11:49 PM
Warning: Cannot modify header information - headers already sent by (output started at /home/www/simplydj.freehostia.com/preview/config.php:13) in /home/www/simplydj.freehostia.com/preview/login.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/www/simplydj.freehostia.com/preview/config.php:13) in /home/www/simplydj.freehostia.com/preview/login.php on line 17


NONE of the codes work
Your host sucks.

You do know how insecure this is.

I could create a cookie called loggedin with the value = yes, and be in.

chrisgocrazyH
02-02-2008, 12:09 AM
im only using Freehostia atm becoz my optus provider has blocked off the port for simplyhabbo.com at home so when i get it back today i should get it to work..

Caleb
02-02-2008, 12:22 AM
Well it seems FreeHostia is blocking an important function that you need ;)

Independent
02-02-2008, 05:13 AM
I made a maintenance system in housekeeping sort of,

I used the DJ says tables and Alert, cos I can't code php =)

lolwut
02-02-2008, 12:08 PM
You do know how insecure this is.

I could create a cookie called loggedin with the value = yes, and be in.
Yes, I do know how insecure this is... It's intended for beginners.
That means someone whos new?
God, what happened to the nice Caleb? >_>

If it was intended for more advanced coders then I'd have used sessions.
Cookies are simple and are good for a PHP first-time programmer.

EDIT: Just noticed a huge error in edit.php:
Replace the previous edit.php code with this code: (I'd be greatful if a Moderator could replace the current edit.php file with the one below on the first post please!)


<?php
require("config.php"); //Includes the configuration file.
if($_COOKIE[loggedin] == "yes"){ //If they're logged in...
if(!isset($_POST['update'])){ //Check to see if they've posted the form yet.
echo("Please choose the setting to edit here:<br />
<form method=\"post\">
Site Status: <select name=\"status\"><option value=\"on\">On</option><option value=\"off\">Off</option></select>
<br />
Offline Message: <input type=\"text\" name=\"offmsg\" size=\"40\">
<br />
Online Page To Redirect To: <input type=\"text\" name=\"onpage\" size=\"30\">
<br />
<input type=\"submit\" value=\"Update!\" name=\"update\">
</form>");
//^^ Show them the form because they haven't posted it yet.
}else{ //If they have posted the form...
$status = $_POST['status']; //Makes the variable easier to handle.
$offmsg = $_POST['offmsg']; //Makes the variable easier to handle.
$onpage = $_POST['onpage']; //Makes the variable easier to handle.
mysql_query("UPDATE `sitestatus` SET `status` = '" . $status . "', `offmsg` = '" . $offmsg . "', `onpage` = '" . $onpage . "' ;"); //Updates the MySQL database with the information they specified in the form.
echo("The site has been succesfully updated!"); //Tells them that the database has been updated.
setcookie("loggedin","",time() - 3600); //Unsets the logged in cookie.
} //End the if statement (if have(n't) posted the form yet.
}else{ //If they're not logged in...
die("Please login to edit the site status!"); //End the if statement(if they're (not) logged in.
} //End the if statment (if not logged in)
mysql_close(); //Closes any remaining MySQL connections.
?>

Independent
02-02-2008, 12:50 PM
Yes, I do know how insecure this is... It's intended for beginners.
That means someone whos new?
God, what happened to the nice Caleb? >_>

If it was intended for more advanced coders then I'd have used sessions.
Cookies are simple and are good for a PHP first-time programmer.

EDIT: Just noticed a huge error in edit.php:
Replace the previous edit.php code with this code: (I'd be greatful if a Moderator could replace the current edit.php file with the one below on the first post please!)


<?php
require("config.php"); //Includes the configuration file.
if($_COOKIE[loggedin] == "yes"){ //If they're logged in...
if(!isset($_POST['update'])){ //Check to see if they've posted the form yet.
echo("Please choose the setting to edit here:<br />
<form method=\"post\">
Site Status: <select name=\"status\"><option value=\"on\">On</option><option value=\"off\">Off</option></select>
<br />
Offline Message: <input type=\"text\" name=\"offmsg\" size=\"40\">
<br />
Online Page To Redirect To: <input type=\"text\" name=\"onpage\" size=\"30\">
<br />
<input type=\"submit\" value=\"Update!\" name=\"update\">
</form>");
//^^ Show them the form because they haven't posted it yet.
}else{ //If they have posted the form...
$status = $_POST['status']; //Makes the variable easier to handle.
$offmsg = $_POST['offmsg']; //Makes the variable easier to handle.
$onpage = $_POST['onpage']; //Makes the variable easier to handle.
mysql_query("UPDATE `sitestatus` SET `status` = '" . $status . "', `offmsg` = '" . $offmsg . "', `onpage` = '" . $onpage . "' ;"); //Updates the MySQL database with the information they specified in the form.
echo("The site has been succesfully updated!"); //Tells them that the database has been updated.
setcookie("loggedin","",time() - 3600); //Unsets the logged in cookie.
} //End the if statement (if have(n't) posted the form yet.
}else{ //If they're not logged in...
die("Please login to edit the site status!"); //End the if statement(if they're (not) logged in.
} //End the if statment (if not logged in)
mysql_close(); //Closes any remaining MySQL connections.
?>

Yes hi edd (ty for ignoring me on msn (N))

Caleb
02-02-2008, 01:28 PM
Yes, I do know how insecure this is... It's intended for beginners.
That means someone whos new?
God, what happened to the nice Caleb? >_>

If it was intended for more advanced coders then I'd have used sessions.
Cookies are simple and are good for a PHP first-time programmer.

EDIT: Just noticed a huge error in edit.php:
Replace the previous edit.php code with this code: (I'd be greatful if a Moderator could replace the current edit.php file with the one below on the first post please!)


<?php
require("config.php"); //Includes the configuration file.
if($_COOKIE[loggedin] == "yes"){ //If they're logged in...
if(!isset($_POST['update'])){ //Check to see if they've posted the form yet.
echo("Please choose the setting to edit here:<br />
<form method=\"post\">
Site Status: <select name=\"status\"><option value=\"on\">On</option><option value=\"off\">Off</option></select>
<br />
Offline Message: <input type=\"text\" name=\"offmsg\" size=\"40\">
<br />
Online Page To Redirect To: <input type=\"text\" name=\"onpage\" size=\"30\">
<br />
<input type=\"submit\" value=\"Update!\" name=\"update\">
</form>");
//^^ Show them the form because they haven't posted it yet.
}else{ //If they have posted the form...
$status = $_POST['status']; //Makes the variable easier to handle.
$offmsg = $_POST['offmsg']; //Makes the variable easier to handle.
$onpage = $_POST['onpage']; //Makes the variable easier to handle.
mysql_query("UPDATE `sitestatus` SET `status` = '" . $status . "', `offmsg` = '" . $offmsg . "', `onpage` = '" . $onpage . "' ;"); //Updates the MySQL database with the information they specified in the form.
echo("The site has been succesfully updated!"); //Tells them that the database has been updated.
setcookie("loggedin","",time() - 3600); //Unsets the logged in cookie.
} //End the if statement (if have(n't) posted the form yet.
}else{ //If they're not logged in...
die("Please login to edit the site status!"); //End the if statement(if they're (not) logged in.
} //End the if statment (if not logged in)
mysql_close(); //Closes any remaining MySQL connections.
?>

I am just telling you, because some person is going to grab that code, and just use it somewhere.. then complain because they got hacked.

;)

MrCraig
02-02-2008, 08:06 PM
Oh fgs.

The last thing you tell 'beginners' how to do is produce insecure code.
They just run round forum going "OMGZ! HOW 1337 AM I? I CAN CODE!?!"

Need to secure the system for it to be of any use...

Dr222
02-02-2008, 09:09 PM
nicely done :)

Westman40
10-05-2008, 10:35 AM
Warning: Cannot modify header information - headers already sent by (output started at /home/habmaste/public_html/[removed]/config.php:13) in /home/habmaste/public_html/[removed]/login.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/habmaste/public_html/[removed]/config.php:13) in /home/habmaste/public_html/[removed]/login.php on line 17


I am also getting these errors! I believe its to do with the cookies thing. I am a bit of a noob at PHP at the moment, is it possible to use sessions? (is so, can anybody attempt it?)

I am using crisphosting at the moment... They dont suck lol. I hope they aint blocking something.

Bonxy
10-05-2008, 11:55 AM
nice....

Bonxy
10-05-2008, 02:49 PM
when i try to run this query i get this message



Error

SQL query:

CREATE TABLE `sitestatus` (
`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM INSERT INTO `sitestatus` ( `id` , `status` , `offmsg` , `onpage` )
VALUES (
'1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://example.com/'
)

MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `sitestatus` (
`id` ,
`status` ,
`offmsg` ,
`onpage`
)
VALUES ' at line 9



anyone know why ?

Bonxy
15-05-2008, 07:28 PM
im getting these errors when i log in


Warning: Cannot modify header information - headers already sent by (output started at /home/HIDDEN/public_html/panel/extras/status/login.php:9) in /home/HIDDEN/public_html/panel/extras/status/login.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home/HIDDEN/public_html/panel/extras/status/login.php:9) in /home/HIDDEN/public_html/panel/extras/status/login.php on line 25

lolwut
24-05-2008, 04:05 PM
All anyone every does these days is moan.

Fully fixed and uses sessions because i couldn't think of a workaround if I used cookies.

NOT TESTED!



MYSQL QUERY (Fixed) :


CREATE TABLE `sitestatus` (
`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY (`id`)
) ENGINE = MYISAM ;

INSERT INTO `sitestatus` ( `id` , `status` , `offmsg` , `onpage` )
VALUES ( '1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://example.com/'
) ;

------------------

CONFIG.PHP :

<?php
//================================================== ============================
$host = "localhost"; //Set this to the database host.
$user = "root"; //Set this to the database username.
$pass = ""; //Set this to the database password.
$name = "users"; //Set this to the database name.
$set_password = "12321"; //Set this to the password you want the user to provide before they're given access to the site.
//================================================== ============================
mysql_connect($host,$user,$pass); //Connects to the database.
mysql_select_db($name); //Selects the database.
$info = mysql_query("SELECT * FROM `sitestatus` WHERE `id` = '1' ;"); //Is getting the information we need.
$i = mysql_fetch_object($info); //Is formatting the information we need.
session_start(); // ;)
?>

------------------

LOGIN.PHP :

<?php
require("config.php"); //Includes the configuration file we made earlier.
if(!isset($_POST['login'])){ //If they haven't posted the login form...
echo("Please enter the password to edit the site status!<br />
<form method=\"post\">
Password: <input type=\"password\" name=\"password\">
<br />
<input type=\"submit\" value=\"Login\" name=\"login\">
</form>");
//^^ Then show the login form so they can login.
}else{ //If they have posted the login form...
$s_password = $_POST['password']; //Change the password variable to something easier to handle.
if($s_password != $set_password){ //If the supplied password doens't match the set password in the configuration file...
die("You did not enter the correct password!"); //Tell them so, and close the session so they can't edit anything.
} //Ends the if statement (the supplied password didn't match the set one)
$_SESSION['loggedin'] = "yes"; //Sets a session with the users information in, will be used in the next step.
header("Location: edit.php"); //Sends them off to the edit info page.
} //End the if statement (the login from hasn't been posted)
mysql_close(); //Close any remaining MySQL connections.
?>

------------------

EDIT.PHP :

<?php
require("config.php"); //Includes the configuration file.
if($_SESSION[loggedin] == "yes"){ //If they're logged in...
if(!isset($_POST['update'])){ //Check to see if they've posted the form yet.
echo("Please choose the setting to edit here:<br />
<form method=\"post\">
Site Status: <select name=\"status\"><option value=\"on\">On</option><option value=\"off\">Off</option></select>
<br />
Offline Message: <input type=\"text\" name=\"offmsg\" size=\"40\">
<br />
Online Page To Redirect To: <input type=\"text\" name=\"onpage\" size=\"30\">
<br />
<input type=\"submit\" value=\"Update!\" name=\"update\">
</form>");
//^^ Show them the form because they haven't posted it yet.
}else{ //If they have posted the form...
$status = $_POST['status']; //Makes the variable easier to handle.
$offmsg = $_POST['offmsg']; //Makes the variable easier to handle.
$onpage = $_POST['onpage']; //Makes the variable easier to handle.
mysql_query("UPDATE `sitestatus` SET `status` = '" . $status . "', `offmsg` = '" . $offmsg . "', `onpage` = '" . $onpage . "' ;"); //Updates the MySQL database with the information they specified in the form.
echo("The site has been succesfully updated!"); //Tells them that the database has been updated.
session_destroy($_SESSION['loggedin']; //Unsets the logged in cookie.
} //End the if statement (if have(n't) posted the form yet.
}else{ //If they're not logged in...
die("Please login to edit the site status!"); //End the if statement(if they're (not) logged in.
} //End the if statment (if not logged in)
mysql_close(); //Closes any remaining MySQL connections.
?>

------------------

INDEX.PHP (Example) :

<?php
require("config.php"); //Includes the configuration file we made earlier.
if($i->status == "on"){ //If the site status is set to on...
header($i->onpage); //Then forward the user to the online page.
}elseif($i->status == "off"){ //If the site status is set to off...
echo("The site is currently in offline mode!<br />The reason for this is: <b>" . $i->offmsg . "</b><br />We appologise for any disturbance this may cause.");
//^^ Then tell them so, and show the offline message.
} //Closes the statement.
mysql_close(); //Stops any MySQL connections we had running.
?>

Decode
24-05-2008, 05:23 PM
I would simply do

maintanance.php


<?php
$maintanance = file_get_contents("maintanance.txt");
if ( $maintanance == "true" ){
echo "site is offline";
exit();
}
?>
2hsus7sjs.php (has a funny name so no one will find it lol)


<?php
if ( $_GET['action'] == "submit" ) {
$maintanance = $_POST['maintanance'];
$changefile = file("maintanance.txt");
$update = fopen($changefile , "w");
fputs($update , "$maintanance");
fclose($update);
}
?>
<form method="post" action="?action=submit">
<table>
<tr><td>Close?</td>
<td>
<select name="maintanance">
<option value="true" selected>Put site offline
<option value="false">Put site Online
</select>
</td></tr><tr><td colspan="2">
<center><input type="submit" value="change"></center>
</td></tr></table>
</form>

Not tested, should work :)

Also, it requires no database.

EDIT: allmost forgot lol, to make the script work add


<?php include("maintanance.php"); ?>

to the index page of your site.

lolwut
25-05-2008, 10:34 AM
Could do, but that's less secure and part of the objective of mine is to help people use databases. :P

Independent
26-05-2008, 07:50 PM
flat file is just too insecure..

Offtopic: Hey edd :P

Bonxy
27-05-2008, 01:36 PM
I would simply do

maintanance.php


<?php
$maintanance = file_get_contents("maintanance.txt");
if ( $maintanance == "true" ){
echo "site is offline";
exit();
}
?>
2hsus7sjs.php (has a funny name so no one will find it lol)


<?php
if ( $_GET['action'] == "submit" ) {
$maintanance = $_POST['maintanance'];
$changefile = file("maintanance.txt");
$update = fopen($changefile , "w");
fputs($update , "$maintanance");
fclose($update);
}
?>
<form method="post" action="?action=submit">
<table>
<tr><td>Close?</td>
<td>
<select name="maintanance">
<option value="true" selected>Put site offline
<option value="false">Put site Online
</select>
</td></tr><tr><td colspan="2">
<center><input type="submit" value="change"></center>
</td></tr></table>
</form>

Not tested, should work :)

Also, it requires no database.

EDIT: allmost forgot lol, to make the script work add


<?php include("maintanance.php"); ?>to the index page of your site.

doesnt work dude.
x

Decode
27-05-2008, 08:59 PM
doesnt work dude.
x
what bit is the problem?

flat file is just too insecure..

Offtopic: Hey edd :P
Does it realy matter if someone reads a text file that says "offline" or "online" in it?

Agnostic Bear
28-05-2008, 07:04 AM
flat file is just too insecure..

Offtopic: Hey edd :P

File based systems can be just as secure as databases.

seniorJOSH
28-05-2008, 07:06 AM
File based systems can be just as secure as databases.

Indeed, although, I found it annoying doing it o_O

Independent
31-05-2008, 05:54 AM
what bit is the problem?

Does it realy matter if someone reads a text file that says "offline" or "online" in it?
Ah I never read the code, I thought it was for the user authentication. :P

Independent
31-05-2008, 06:09 AM
SQL query:
CREATE TABLE `sitestatus` ( `id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM INSERT INTO `sitestatus` ( `id` , `status` , `offmsg` , `onpage` )
VALUES ( '1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://www.radioaqua.net/'
)
MySQL said: http://www.nivade.com:2082/3rdparty/phpMyAdmin/themes/original/img/b_help.png (http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html)
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `sitestatus` (
`id` ,
`status` ,
`offmsg` ,
`onpage`
)
VALUES ' at line 9

I'm no MySQL Guru, someone help (A)

Couldn't edit the other one after 15 minutes.

Bonxy
31-05-2008, 11:48 AM
I would simply do

maintanance.php


<?php
$maintanance = file_get_contents("maintanance.txt");
if ( $maintanance == "true" ){
echo "site is offline";
exit();
}
?>
2hsus7sjs.php (has a funny name so no one will find it lol)


<?php
if ( $_GET['action'] == "submit" ) {
$maintanance = $_POST['maintanance'];
$changefile = file("maintanance.txt");
$update = fopen($changefile , "w");
fputs($update , "$maintanance");
fclose($update);
}
?>
<form method="post" action="?action=submit">
<table>
<tr><td>Close?</td>
<td>
<select name="maintanance">
<option value="true" selected>Put site offline
<option value="false">Put site Online
</select>
</td></tr><tr><td colspan="2">
<center><input type="submit" value="change"></center>
</td></tr></table>
</form>

Not tested, should work :)

Also, it requires no database.

EDIT: allmost forgot lol, to make the script work add


<?php include("maintanance.php"); ?>to the index page of your site.

Id tell anyone to use this one.

you just copy and paste everything and then ChMOD maintanance.txt so it is 777 and it works.

There is nothing up with it.

:)

Independent
04-06-2008, 10:17 AM
Id tell anyone to use this one.

you just copy and paste everything and then ChMOD maintanance.txt so it is 777 and it works.

There is nothing up with it.

:)
Then that's a flatfile maintenance system. ;) rofl

Decode
06-06-2008, 03:23 PM
Then that's a flatfile maintenance system. ;) rofl
Whats wrong with that ;)

Independent
06-06-2008, 03:34 PM
Whats wrong with that ;)
I was just stating rofl.

Amiten
27-06-2008, 02:09 PM
umm problem when i enter my sql thing this error comes up :9 im ok with html but cant get hy head around my sql could anyone help? thanks



Error
SQL query:

CREATE TABLE `sitestatus` (

`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM INSERT INTO `sitestatus` ( `id` , `status` , `offmsg` , `onpage` )
VALUES (
'1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://example.com/'
)

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `sitestatus` (
`id` ,
`status` ,
`offmsg` ,
`onpage`
)
VALUES ' at line 9



tom

Independent
28-06-2008, 08:25 AM
umm problem when i enter my sql thing this error comes up :9 im ok with html but cant get hy head around my sql could anyone help? thanks



Error
SQL query:

CREATE TABLE `sitestatus` (

`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM INSERT INTO `sitestatus` ( `id` , `status` , `offmsg` , `onpage` )
VALUES (
'1', 'off', 'The site is currently offline for some much needed maintenance work on the frameworks!', 'http://example.com/'
)

MySQL said:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `sitestatus` (
`id` ,
`status` ,
`offmsg` ,
`onpage`
)
VALUES ' at line 9

tom
I had this problem too;

Remove the insert bits, and put this only execute this query:


CREATE TABLE `sitestatus` (
`id` INT( 2 ) NOT NULL AUTO_INCREMENT ,
`status` VARCHAR( 10 ) NOT NULL ,
`offmsg` TEXT NOT NULL ,
`onpage` VARCHAR( 50 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM

Calon
02-08-2008, 02:56 AM
I was in the middle of writing new code for Ed's system, but I have to go.

Turbocom
17-08-2008, 05:55 AM
Warning: Cannot modify header information - headers already sent by (output started at /home/vivhost/public_html/maintenance/config.php:13) in /home/vivhost/public_html/maintenance/login.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/vivhost/public_html/maintenance/config.php:13) in /home/vivhost/public_html/maintenance/login.php on line 17

-leestrong-
11-05-2009, 03:46 PM
Nice and simple.
Well done!

- Lee

Want to hide these adverts? Register an account for free!