I have the following code and a text file with contents of "test1-test70" but for some reason when I enter test1 it deletes test1-10. how do I limit it to delete specifically what I tell it to?
here is the code.
<?
$filename = "./foo.txt";
$fd = fopen ($filename, "r");
?>
<form action=test.php method=post>
Name to be deleted: <input type=text name=DELETE value="">
<input type=submit name=submit value="DELETE USER">
<?
if ($submit)
{
echo"<br><br><b>DELETING: $DELETE</b><br><br>";
$m_line=0;$tmp_line=0;$line=0;
$m_filename = "./foo2.txt";
$m_fd = fopen($m_filename, "w");
while (!feof ($fd)){
$buffer = fgets($fd, 4096);
$pos = strpos ($buffer,$DELETE);
if ($pos === false and $line==0){
fputs ($m_fd,$buffer);
}
else{
if ($tmp_line < $m_line){
$tmp_line = $tmp_line + 1;
$line = 1;
}
else{
$line = 0;
echo "<b>DELETED: $DELETE</b><br><br>";
}
}
}
fclose($fd);
fclose($m_fd);
copy("./foo2.txt","./foo.txt");
}
?>