PHP text editing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
benito88
Forum Newbie
Posts: 1
Joined: Sat Jan 22, 2005 6:41 am

PHP text editing

Post by benito88 »

hi, i did a small script to edit a txt file though IE but everytime i edit the txt when i put ' or \ it put another \ before it :?

any one can correct my code plz?

edit.php

Code: Select all

<?

$filename = "../sport.txt";
$fp = fopen ($filename, "rw");

echo "<form method=post action=process.php>\n";

echo "<textarea rows='6' cols='40' name='content'>\n";


$content = fread ($fp, filesize ($filename));
echo $content;

echo "</textarea><br><br>";

fclose ($fp);

echo "<input type=submit value=Submit>\n";

echo "</form>";

?>
process.php

Code: Select all

<?

$filename = "../sport.txt";

$fp = fopen ($filename, "w");

// write to file
if (!fwrite($fp, $_POST&#1111;'content'])) &#123;
   echo "Unable to modify the file";
   exit;
&#125;

echo "Successful!";

fclose($fp);

?>
where is the error??

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

stripslashes()

search the forums for "magic quotes"

it's a fun "feature"
Post Reply