Page 1 of 1

PHP text editing

Posted: Sat Jan 22, 2005 6:47 am
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

Posted: Sat Jan 22, 2005 7:56 am
by feyd
stripslashes()

search the forums for "magic quotes"

it's a fun "feature"