I've just written this, but for some reason, logging in won't work, and even if I remove the login part, editing the page doesn't work either. What's wrong with my coding? The folder has CHMOD 777 and the data file was created by the script...Code:<?php /***************************************************\ * Easy-edit page script by anger2headshot * * Version 0.1 * * http://a2h.uni.cc * * an a2h project * * licensed under CC-BY-NC-ND-2.5-AU * \***************************************************/ //////////////////////////////////////////////////////// // configure here // //////////////////////////////////////////////////////// // username $user1name="username"; // password $pass1word="password"; // page name $pagename="gmcrnews"; //////////////////////////////////////////////////////// // dont edit further unless you know what youre doing // //////////////////////////////////////////////////////// // page location $pageloc = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER["SCRIPT_NAME"]; // check whether data exists if (file_exists($pagename.".dat")) { $pagemade=1; $pagecontents = file_get_contents($pagename.".dat"); } else { $pagemade=0; $pagecontents=""; $file=fopen($pagename.".dat","x"); fclose($file); } // check whether logged in if ($_POST["username"]==$user1name) { if ($_POST["password"]==$pass1word) { $logged=true; } else { $logged=false; } } else { $logged=false; } // editing the page? if ($_POST["submitting"]=="lolz") { $file=fopen($pagename.".dat","w"); fwrite($file,$_POST["newcontent"]); fclose($file); $edited=1; } else { $edited=0; } // check whether user wants raw data, if so, give the data and exit if ($_GET["raw"]==1) { if ($pagemade==1) { echo $pagecontents; exit(); } } ?> <html> <head> <title>Easy-edit page script by anger2headshot</title> </head> <body> <?php // not logged in? time to login... if ($logged==false) { echo 'Please login to edit this page.<br /> <form action="' . $pageloc .'" method="post"> Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /> <input type="submit" value="Login" /></form>'; } else { ?> Logged in.<br /> <?php if ($edited==1) { echo '<b>Your edit has been saved!</b><br />';} ?> <form action="<?php echo $pageloc; ?>" method="post"> <input type="hidden" name="submitting" value="lolz" /> <textarea rows="5" cols="30" name="newcontent"> <?php echo $pagecontents; ?> </textarea><br /> <input type="submit" value="Edit page" /></form> <?php } ?> </body> </html>



Reply With Quote
Bookmarks