Log in

View Full Version : ?page=var // stripslashes cmd



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

vpnprgm
01-22-2007, 01:54 PM
<?
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");
}
?>
<head>
<script language="JavaScript" type="text/javascript" src="Editor/wysiwyg.js">
</script>
</head>

<form action="" method="post">
<textarea Name="update" id="tid" cols="50" rows="10"></textarea>
<script language="javascript">
generate_wysiwyg('tid');
</script>

<input name="Submit" type="submit" value="Update" />
</form>


in this <script language="JavaScript" type="text/javascript" src="Editor/wysiwyg.js">, here src="Editor/wysiwyg.js"
is the path i saved that js file. download wysiwyg.js
In textarea id="tid" and that tid is pass generate_wysiwyg('tid') function

i am not sure, this is the output you want.


second part i did'nt get you, but if you explain about that little more, i will try to help you

Regards
Vijay:) :)