Why is my form inserting backslashes before quotes?

127 Views Asked by At

My php code to edit a text document is adding a backslash anywhere a ' or a " is used and I can't figure out why. Anybody ever ran into this before? How did you fix it?

<? 
if($_POST['Submit']){ 
$open = fopen("../content.txt","w+"); 
$text = $_POST['update']; 
fwrite($open, $text); 
fclose($open); 
echo "File updated.<br />";  
echo "File:<br />"; 
$file = file("../content.txt"); 
foreach($file as $text) { 
echo $text."<br />"; 
} 
}else{ 
$file = file("../content.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>"; 
} 
?>

So when I type for instance

<a href="index.php">Home</a>

It saves looking like this

<a href=/"index.php/">Home</a>

Output

After save

0

There are 0 best solutions below