Fadion Posted April 21, 2008 Share Posted April 21, 2008 Cmon guys, he's not asking a fully working facebook clone, he just needs some guides. It feels like being in an auction here. mate u need to have a config.php file where u can define a constant with the site maintaince value (on/off). In the admin panel make a checkbox and depending to its state (checked or not) write that value to config.php using php file handling functions, fopen() fread() and fwrite(). U dont need a mysql db for this. Just write the complete file with the <?php ?> tags, the constant and everything ure planning to put into. About the login, make a form with one input (type=password) and when it is set check if it is 123456, then redirect: <?php if(isset($_POST['password'])){ if($_POST['password'] == '123456'){ header("Location: admin.php"); } else{ echo 'Incorrect password'; } } ?> Hope these helped. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522326 Share on other sites More sharing options...
ohdang888 Posted April 21, 2008 Share Posted April 21, 2008 wow to everyone on this forum.... except a few select people... your question is fairly simple... create a table in MYSQL called 'test', with 2 columns, "id" and "answer" and insert a row into it with id=1 and answer=yes on the page...connect to the db, select a db, and do this $result = mysql_query("SELECT answer FROM test WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array($result); if($row['answer'] == 'yes'){ show yes answer info }elseif($row['answer'] == 'no'){ show no answer info } to update it... create a form...then make action.php on action.php, do something like this $update = $_POST['answer'] mysql_query("UPDATE test SET `answer`='$update' WHERE `id`='1' ") Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522364 Share on other sites More sharing options...
Fadion Posted April 21, 2008 Share Posted April 21, 2008 Using a database is a way, but isnt it a bit overwhelming? Usually site-related config variables are best to be kept in a config file where can just be included and used like normal variables and u dont have additional queries too. Anyway it is an easier method, but not as efficient. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522369 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 i use sql database and .inc.php file(this is simpiler and requires less work) Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522371 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Author Share Posted April 21, 2008 wow to everyone on this forum.... except a few select people... your question is fairly simple... create a table in MYSQL called 'test', with 2 columns, "id" and "answer" and insert a row into it with id=1 and answer=yes on the page...connect to the db, select a db, and do this $result = mysql_query("SELECT answer FROM test WHERE id='1'") or die(mysql_error()); $row = mysql_fetch_array($result); if($row['answer'] == 'yes'){ show yes answer info }elseif($row['answer'] == 'no'){ show no answer info } to update it... create a form...then make action.php on action.php, do something like this $update = $_POST['answer'] mysql_query("UPDATE test SET `answer`='$update' WHERE `id`='1' ") thanks man, even though it didn't work, thanks for your time and patience to write this code, unlike some people. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522487 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 my offer is still there Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522489 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 dude are you really that stuck?? If so i will write the code, for free, but just a basic one. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522503 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Author Share Posted April 21, 2008 i don't need the code, i just WANT the code, i wanna boost up my php skills and thats it. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522508 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 ok, what do u want it to do? database? etc. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522512 Share on other sites More sharing options...
ohdang888 Posted April 21, 2008 Share Posted April 21, 2008 i'm on AIM for another 20 minteus or so... i'll help you there... my sn is: ohdang10 Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522522 Share on other sites More sharing options...
Fadion Posted April 21, 2008 Share Posted April 21, 2008 To cut it short. Make a config.php (or config.inc.php to distinguish included files) file: <?php //config.php define('CONSTRUCTION', 'no'); ?> Then in the admin panel make a list or checkbox or whatever with yes, no value. Im going for the list (which im sure u know how to make): <?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> To use it: <?php include('config.php'); if(CONSTRUCTION == 'yes'){ echo 'Site is under construction'; } else{ //other code } ?> Hope it makes things clear. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522526 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Author Share Posted April 21, 2008 Then in the admin panel make a list or checkbox or whatever with yes, no value. Im going for the list (which im sure u know how to make): like this? admin.php <?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> <form action=""> <select name="construction"> <option value="yes">yes</option> <option value="no">no</option> </select> <input type="submit" value="submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522530 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Author Share Posted April 21, 2008 this is what i have so far vvvvvvvvvvvvvvv index.php <?php include('config.php'); if(CONSTRUCTION == 'yes'){ echo 'Site is under construction'; } else{ echo 'LOL'; } ?> config.php <?php //config.php define('CONSTRUCTION', 'no'); ?> admin.php <?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> <form action=""> <select name="construction"> <option value="yes">yes</option> <option value="no">no</option> </select> <input type="submit" value="submit"> </form> it doesn't seem to work Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522538 Share on other sites More sharing options...
ohdang888 Posted April 21, 2008 Share Posted April 21, 2008 <form action="admin.php"> Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522541 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 <form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit"> if it doesn't work add these, input type before the other input type Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522549 Share on other sites More sharing options...
Fadion Posted April 21, 2008 Share Posted April 21, 2008 Modify as suggested and if it still doesnt work, tell where it is stuck. Does it get post data? Does it write config.php after the submit? Is config.php in the same directory as the other files? Does it trigger any error? Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522551 Share on other sites More sharing options...
DeanWhitehouse Posted April 21, 2008 Share Posted April 21, 2008 <?php if(isset($_POST['construction'])){ $construction = $_POST['construction']; $handle = fopen('config.php', 'w+'); //open the file for writing $content = "<?php define('CONSTRUCTION', '{$construction}'); ?>"; //the content to be written fwrite($handle, $content); //write it fclose($handle); } ?> <form action="<?php $_SERVER['PHP_SELF']; ?>" method='POST'> <select name="construction"> <option value="yes">yes</option> <option value="no">no</option> </select> <input type="hidden" name="construction" value="true"><input type="submit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522554 Share on other sites More sharing options...
dezkit Posted April 21, 2008 Author Share Posted April 21, 2008 Modify as suggested and if it still doesnt work, tell where it is stuck. Does it get post data? Does it write config.php after the submit? Is config.php in the same directory as the other files? Does it trigger any error? actually, it doesn't do anything... but you know what, i'll scim through php.net and i will learn everysingle function. thanks everybody! topic solved. Quote Link to comment https://forums.phpfreaks.com/topic/101932-solved-php-under-construction-admin/page/2/#findComment-522841 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.