replacing text in file in php?

  • Thread starter Thread starter jmeson79
  • Start date Start date
J

jmeson79

Guest
i have a text file called report.txt, and i have a php file with a form that has two textarea's. one textarea is for the user to specify the string they want to find (named "old"), and the other textarea is for the user to specify the string they want to replace (named "new"). i have another php file with code that is supposed to replace the old string with the new string:

<?php
if (file_exists("report.txt")) {
$filetext = file_get_contents("report.txt");
$filetext = str_replace($_REQUEST['old'], $_REQUEST['new'], $filetext);
file_put_contents("report.txt", $filetext);
}

?>

but this isn't working. does anyone know what i've done wrong?
 
Back
Top