I'm using a form to gather some information and store it to a file, but if the same information is entered, I want to let the user know the info has been entered. Basically I want to do this:
$linetowrite=$userid."|".$experiment."|".$yearlastused."|".$termlastused."|".$weeklastused."|".$then umber;
$dateandtime=&thedate();
open(FILEDATABASE,'textfiles/lastuse.db');
@data = <FILEDATABASE>;
close(FILEDATABASE);
$writeit=1;
foreach $line(@data){
if($line =~ /$linetowrite/){
&printError('This information already exists!');
$writeit=0;
}
}
if($writeit==1){
open(FILEDATABASE,'>>textfiles/lastuse.db');
print FILEDATABASE $linetowrite."|".$dateandtime."\n";
print 'Data written';
close(FILEDATABASE);
}
Fairly simple code but my matching condition is always true regardless of input (after the first entry). Is there something wrong with my quotes? That's all I can think of. I wanted to put in the upload time separately so it wouldn't try to match that in the linetowrite variable.
Thanks in advance from yet another newbie question.
RTP
$linetowrite=$userid."|".$experiment."|".$yearlastused."|".$termlastused."|".$weeklastused."|".$then umber;
$dateandtime=&thedate();
open(FILEDATABASE,'textfiles/lastuse.db');
@data = <FILEDATABASE>;
close(FILEDATABASE);
$writeit=1;
foreach $line(@data){
if($line =~ /$linetowrite/){
&printError('This information already exists!');
$writeit=0;
}
}
if($writeit==1){
open(FILEDATABASE,'>>textfiles/lastuse.db');
print FILEDATABASE $linetowrite."|".$dateandtime."\n";
print 'Data written';
close(FILEDATABASE);
}
Fairly simple code but my matching condition is always true regardless of input (after the first entry). Is there something wrong with my quotes? That's all I can think of. I wanted to put in the upload time separately so it wouldn't try to match that in the linetowrite variable.
Thanks in advance from yet another newbie question.
RTP