shmeeg Posted September 21, 2011 Share Posted September 21, 2011 Can't figure out why the page wont save after clicking save. $KOHDE="index.php?s=admin"; $LOMAKE_W = 400; $TEXTAREA_W = 50; $TEXTAREA_H = 20; $LOMAKE = mysql_real_escape_string($_GET["l"]); $LOMAKE2 = mysql_real_escape_string($_POST["lomake"]); after a few more lines... elseif ($LOMAKE2 == "etusivu"){ #Etusivun muokkaus $teksti = stripslashes($_POST["teksti"]); $f = fopen("etusivu.php", "w"); fwrite($f, $teksti); fclose($f); } elseif ($LOMAKE == "etusivu"){ #Etusivun muokkaus echo "<h1>Edit home page</h1>"; $f = file("etusivu.php"); echo "<form action='$KOHDE' method='post'> <textarea name='teksti' cols='$TEXTAREA_W' rows='$TEXTAREA_H'>"; for ($i = 0; $i < count($f); $i++){ $f[$i] = str_replace("\"", "''", $f[$i]); echo $f[$i]; } echo "</textarea> <input type='hidden' value='etusivu' name='lomake'/> <br><input type='submit' value='Save'/> </form><br/>"; html_ohje(); } I can't see where it has gone wrong. Can anyone help? Link to comment https://forums.phpfreaks.com/topic/247600-pages-not-saving-using-file-fopen-fwrite-fclose/ Share on other sites More sharing options...
PFMaBiSmAd Posted September 21, 2011 Share Posted September 21, 2011 Do you have a database connection so that mysql_real_escape_string would work? Also, why are you escaping data and then stripping the escape characters back out for data being written to a file? Link to comment https://forums.phpfreaks.com/topic/247600-pages-not-saving-using-file-fopen-fwrite-fclose/#findComment-1271460 Share on other sites More sharing options...
shmeeg Posted September 21, 2011 Author Share Posted September 21, 2011 Yes I have a database connection. I'm not sure about the second part. I'm sure that's not what the error is though? Link to comment https://forums.phpfreaks.com/topic/247600-pages-not-saving-using-file-fopen-fwrite-fclose/#findComment-1271469 Share on other sites More sharing options...
PFMaBiSmAd Posted September 21, 2011 Share Posted September 21, 2011 Have you confirmed that $LOMAKE2 actually has "etusivu" in it? Link to comment https://forums.phpfreaks.com/topic/247600-pages-not-saving-using-file-fopen-fwrite-fclose/#findComment-1271474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.