Slash Problems When Using PHP and POST.

From: Date: Wed, 18 Jul 2001 19:45:06 +0000
Subject: Slash Problems When Using PHP and POST.
Groups: php.general 
Request: Send a blank email to php-general+get-58526@lists.php.net to get a copy of this message
I have created a php page that loads a file into a textarea. You can then edit the file and click "Save" and it POSTS it to the same page (edit.php) on the server. It saves it but it adds slashes before any speech marks (""). Can somebody please help me with this. It changes: <meta name="author" content="Corin Rathbone 2001"> to: <meta name=\"author\" content=\"Corin Rathbone 2001\"> Below is the code for the page edit.php: <?php include "config.php"; if(isset($save)){ $fp = fopen("$file", "wb") or die("Could not open file!"); $worked = fwrite($fp, $contents) or die("Could not write file!"); fclose($fp) or die("Could not close file!"); $edit=false; $save=true; } elseif(isset($file)){ $fp = fopen("$file", "rb") or die("Could not open file!"); $contents = fread($fp, filesize($file)) or die("Could not read file!"); fclose($fp) or die("Could not close file!"); $edit=true; $save=false; } else{ $edit=false; $save=false; } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Edit A File - File Explorer For <?php print($root_url);?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="author" content="Corin Rathbone webmaster@corirn.org.uk"> <meta name="copyright" content="Corin Rathbone 2001"> <link rel="stylesheet" type="text/css" href="main.css"> </head> <body> <!-- Start Of Page Content --> <div class="heading">Edit A File</div> <?php if($edit){ print( "Contents Of file: <b>" ); print( "$file" ); print( "</b>\n" ); print( "<p align=\"center\">\n" ); print( " <form action=\"edit.php\" method=\"post\" >\n" ); print( "<input type=\"hidden\" name=\"file\" value=\"" ); print( "$file" ); print( "\">\n" ); print( "<input type=\"hidden\" name=\"save\" value=\"1\">" ); print( " <textarea name=\"contents\" rows=\"25\" cols=\"90\">\n" ); print( "$contents" ); print( " </textarea><br>\n" ); print( " <input type=\"submit\" value=\"Save\">\n" ); print( " </form>\n" ); print( "</p>" ); } elseif($save){ print( "<p align=\"center\">\n" ); print( "File: <b>" ); print( "$file" ); if($worked){print( "</b> has been saved!" );} else {print( "</b> has <b>not</b> been saved!" );} print( "</p>" ); } else { print( "<p align=\"center\"><b>Please Select A File To Be Save!</b></p>" ); } ?> <!-- End Of Page Content --> <BR><BR><BR> <div class="copyright">&copy;<a href="mailto:webmaster@corin.org.uk">Corin Rathbone</a> 2001</div> </body> </html> Regards, Corin Rathbone www.corin.org.uk

« previous php.general (#58526) next »