Hi I have a textarea that writes to a .txt file, but it adds / next to " or ' I have been reading up on addslashes, but I can't implement it right <?php if (isset( $_POST )) $postArray = &$_POST ; // 4.1.0 or later else $postArray = &$HTTP_POST_VARS ; // prior to 4.1.0 $fname="post.txt"; $nfile = fopen($fname, "w"); if($nfile != false) { foreach ($postArray as $sForm => $value ) { fwrite($nfile, $value); } fclose($nfile); } ?> PHP: Thats my php code in the post.php and here is my form: <form action="post.php" method="post"> <textarea name="post" id="post"><? include ('post.txt') ?></textarea> <script language="JavaScript"> generate_wysiwyg('post'); </script> <br /> <br /> <input type="submit" value="Confirm Changes"> </form> PHP: If anyone could help I would really appreciate it
Probably your Webserver is escaping the quote characters automatically. You don't need to use addslashes in your case, you need stripslashes Try this: if (get_magic_quotes_gpc()) { fwrite ($nfile, stripslashes($value)); } else fwrite ($nfile, $value); Code (markup): Depending on who is submitting the form, if it isn't you, i would recommend checking the user input anyways...
you put that inside your foreach statement if($nfile != false) { foreach ($postArray as $sForm => $value ) { if (get_magic_quotes_gpc()) { fwrite ($nfile, stripslashes($value)); } else { fwrite ($nfile, $value); } fclose($nfile); }