OK, this could get long but o well. Once the user logs in they have multiple things to delete in a file. For example, the file may have:
string of HTML1
string of HTML2
string of HTML3
string of HTML4
If I choose to delete any of these, it does it ok, except if I choose to delete the first line. If I want to delete the first line, it deletes it all. The input for the script looks like this:
<P><INPUT type="checkbox" name="conform[]" value="<?echo $i++;?>">Delete<?echo "$split[0]\n";?>
This is so the user can delete any amount he wants. But like I said, if he chooses to delete the first one, the whole file is gone, otherwise it deletes just the line specified. Here is the PHP code that deletes the line(s) in the file.
$i = 1;
for ($num=0;$num < count($conform);$num++){
$signersfile = fopen("$hiduser.comments","r");
while (!feof ($signersfile)){
$signers = fgets($signersfile,4096);
$split = split("\n", $signers);
if($split[0] != ""){
if($i == $conform[$num]){
$results = file("$hiduser.comments");
$newword = "";
$oldword = $split[0];
while (list(,$path) = each($results)){
$parts = explode('\n', $path);
$path = $parts[0];
$fp = fopen("$hiduser.comments", 'r');
if ($fp){
$data = fread($fp, filesize("$hiduser.comments"));
fclose($fp);
$newdata = str_replace($oldword, $newword, $data);
$fp = fopen("$hiduser.comments", 'w');
if($fp){
fwrite($fp,$newdata);
fclose($fp);
$succ = "1";
}
}
}
}
else{$i++;}
}
}
}
if($succ == "1"){echo "<P>All done! If you would like to make more changes, click <A HREF=guestbook.php3?action=login&username=$hiduser>here</A>.";}
else{echo "<P>Error!";}
HELP!! Its driving me mad! Any ideas?