The following php script is not replacing text in a file as expected, It writes this to the file >>Resource id #1.
Any suggestions? copy script below and try it.
1. You will need to create a text file
2. You will enter that file name in the form and enter a old word and a new word to replace and hit submit
<?
$form_block ="
<form method=POST action=\"$_SERVER[PHP_SELF]\">
file name<br>
<INPUT type=\"text\" name=\"filename\" size=30><br>
Old name<br>
<INPUT type=\"text\" name=\"old\" size=30>
New Name
<INPUT type=\"text\" name=\"new\" size=30>
 <input type=\"submit\" name=\"submit\" value=\"go\">
</FORM>";
$filename = "$POST[filename].txt";
$old = "$POST[old]";
$new = "$_POST[new]";
$fp = fopen($filename, "r+") or die("Couldn't create file.");
$thefile = fread($fp, filesize($filename) );
$thefile = str_replace($old , $new , $fp);
fwrite($fp, $thefile);
?>
<HTML>
<HEAD>
<TITLE>Creating a New File</TITLE>
</HEAD>
<BODY>
<? echo "$form_block"; ?>
<? echo "$msg"; ?>
</BODY>
</HTML>