beau
01-21-2007, 12:28 AM
Hi everyone,
i need some assistance with simple code. First, I am using this script (http://www.dynamicdrive.com/forums/archive/index.php/t-4539.html) to open txt includes and edit the contents for an easy admin panel. However im having a hard time
Call stripslashes() on the data before writing it..
This is the code:
<?
if($_POST['Submit']){
$open = fopen("textfile.txt","w+");
$text = $_POST['update'];
fwrite($open, $text);
fclose($open);
echo "File updated.<br />";
echo "File:<br />";
$file = file("textfile.txt");
foreach($file as $text) {
echo $text."<br />";
}
echo "<p><a href=\"./livepage.php\">click here to view the live updated webpage</a></p>";
echo "<p><a href=\"./mainadminpage.php\">click here to view the admin menu</a></p>";
}else{
$file = file("textfile.txt");
echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";
foreach($file as $text) {
echo $text;
}
echo "</textarea>";
echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
</form>";
}
?>
oh and if anyone wants to show me how to incorporate a WYSIWYG editor into the txt field so people dont know html to edit that would be great.
Also, for my admin panel, i want to be able to goto, for example:
index.php?page=aboutus and that aboutus var would be added to that code to include that txt file. i think its like global vars or something. I used to play around with php awhile ago, but ive seem to forgotten alot :(
any help would be greatly appriciated.
thank you
i need some assistance with simple code. First, I am using this script (http://www.dynamicdrive.com/forums/archive/index.php/t-4539.html) to open txt includes and edit the contents for an easy admin panel. However im having a hard time
Call stripslashes() on the data before writing it..
This is the code:
<?
if($_POST['Submit']){
$open = fopen("textfile.txt","w+");
$text = $_POST['update'];
fwrite($open, $text);
fclose($open);
echo "File updated.<br />";
echo "File:<br />";
$file = file("textfile.txt");
foreach($file as $text) {
echo $text."<br />";
}
echo "<p><a href=\"./livepage.php\">click here to view the live updated webpage</a></p>";
echo "<p><a href=\"./mainadminpage.php\">click here to view the admin menu</a></p>";
}else{
$file = file("textfile.txt");
echo "<form action=\"".$PHP_SELF."\" method=\"post\">";
echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";
foreach($file as $text) {
echo $text;
}
echo "</textarea>";
echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n
</form>";
}
?>
oh and if anyone wants to show me how to incorporate a WYSIWYG editor into the txt field so people dont know html to edit that would be great.
Also, for my admin panel, i want to be able to goto, for example:
index.php?page=aboutus and that aboutus var would be added to that code to include that txt file. i think its like global vars or something. I used to play around with php awhile ago, but ive seem to forgotten alot :(
any help would be greatly appriciated.
thank you