Hi peeps,
I am running a web application which I can track orders from a unique order number, I am trying to stop my application from adding one to the order no when it has already done it once. (ie I dont want the orderno to go up if a user hits the refresh button). The code generates a .dat file holding all the order info so I check to see if the file is created.
This is the code I am using but it doesn't work!!!
It does seem to function to a degree but it is very unstable. Any ideas?
#Get OrderNo for filename
open(INFILE,"$ENV{'DOCUMENT_ROOT'}/compaq/orderno.dat"
or die "Can not open KPorderNo data file";
$orderno = <INFILE>;
close(INFILE);
#Check for data file
$file = "$ENV{'DOCUMENT_ROOT'}/compaq/orders/$orderno.dat";
unless(-e $file)
{
#Move order number on
open(INFILE,">$ENV{'DOCUMENT_ROOT'}/compaq/orderno.dat"
or die "Can not open KPorderNo data file";
$neword = sprintf("%06d",$orderno+1);
print INFILE "$neword";
close(INFILE);
}
I am running a web application which I can track orders from a unique order number, I am trying to stop my application from adding one to the order no when it has already done it once. (ie I dont want the orderno to go up if a user hits the refresh button). The code generates a .dat file holding all the order info so I check to see if the file is created.
This is the code I am using but it doesn't work!!!
It does seem to function to a degree but it is very unstable. Any ideas?
#Get OrderNo for filename
open(INFILE,"$ENV{'DOCUMENT_ROOT'}/compaq/orderno.dat"
$orderno = <INFILE>;
close(INFILE);
#Check for data file
$file = "$ENV{'DOCUMENT_ROOT'}/compaq/orders/$orderno.dat";
unless(-e $file)
{
#Move order number on
open(INFILE,">$ENV{'DOCUMENT_ROOT'}/compaq/orderno.dat"
$neword = sprintf("%06d",$orderno+1);
print INFILE "$neword";
close(INFILE);
}