x_goose_x
02-19-2003, 12:26 AM
I have only recently begun to look at php (approx 3 hours now). I've figured out the majority of the basics. I have a script that reads a text document into a textarea then when you submit it saves the changes. The problem is, whenever there is a quote sign (single or double) it automatically gets escaped (\ gets added). How can I make it so it doesn't do this?
<?
$filename = "file.php";
$fp = fopen ($filename, "rw");
echo "<form method=post action=write.php>\n";
echo "<textarea id='txt' rows='8' cols='80' 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>";
?>
write.php:
<?
$filename = "file.php";
$fp = fopen ($filename, "w");
if (!fwrite($fp, urldecode($_POST['content']))) {
echo "Could Not Write to file";
exit;
}
echo "Information Written Successfully";
echo "<script language='javascript'>location.replace('edit.php');</script>";
fclose($fp);
?>
I figure you need to use serialize() or urldecode(), but not sure how to use them. Any help/advice would be greatly appreciated. Thanks in advance.
-x_goose_x
<?
$filename = "file.php";
$fp = fopen ($filename, "rw");
echo "<form method=post action=write.php>\n";
echo "<textarea id='txt' rows='8' cols='80' 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>";
?>
write.php:
<?
$filename = "file.php";
$fp = fopen ($filename, "w");
if (!fwrite($fp, urldecode($_POST['content']))) {
echo "Could Not Write to file";
exit;
}
echo "Information Written Successfully";
echo "<script language='javascript'>location.replace('edit.php');</script>";
fclose($fp);
?>
I figure you need to use serialize() or urldecode(), but not sure how to use them. Any help/advice would be greatly appreciated. Thanks in advance.
-x_goose_x