comparing lines
Posted: Thu May 30, 2002 2:41 pm
well on my quest to figure out how to make it so someone can not refresh and re-send the same information, i thought it would be best to check the latest entry of a file, and if it is the same as the submitted form, don't add it...
here is what i came up with, for some reason it doesnt work..
for some reason it always writes the content... any ideas?
here is what i came up with, for some reason it doesnt work..
Code: Select all
$talkdatafile = "tc.txt";
if ($action == "talk") {
if(strlen($nick) >= 3 OR strlen($nick) <= 16){
if(strlen($stuffsaid) >= 3 OR strlen($stuffsaid) <= 60){
if($nick != "Name"){
if($stuffsaid != "Message"){
$t_fp = fopen ($talkdatafile, "a+");
$ip = getenv(REMOTE_ADDR);
$nicktwo = ereg_replace('<', ' ', $nick);
$nickthree = ereg_replace('>', ' ', $nicktwo);
$one_stuffsaid = ereg_replace('<', ' ', $stuffsaid);
$two_stuffsaid = ereg_replace('>', ' ', $one_stuffsaid);
$snickthree = stripslashes($nickthree);
$stwo_stuffsaid = stripslashes($two_stuffsaid);
$writedata = $snickthree."|".$stwo_stuffsaid."|".$ip."|";
$test_last = file($talkdatafile);
$test_lastr = array_reverse($test_last);
$last_e = $test_lastrї0];
if($writedata != $last_e){
fwrite ($t_fp, $writedata."\n");
fclose ($t_fp);
}
}
}
}
}
}