I have been looking over this code for a few hours. I have removed each different if statement to see if it was causing the error..nope. I am getting a 500 error. Please help my poor eyes.
#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse;
#remove '$' character from price field
$in{'price'} =~ s/\$//g;
if ($in{'password'}eq"" || $in{'year'}eq"" || $in{'winery'}eq"" || $in{'wine'}eq"" || $in{'price'}eq""
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<form action=" method="POST">
<P>You forgot to fill in one or more of the fields below. Please try again.</P>
<P>Password: <BR>
<input type="password" name="password" value="$in{'password'}"></P>
<P>Year: <BR>
<input type="text" name="year" value="$in{'year'}">
</P>
<P>Winery:<BR>
<input type="text" name="winery" value="$in{'winery'}">
</P>
<P>Wine:<BR>
<input type="text" name="wine" value="$in{'wine'}">
</P>
<P>Price:<BR>
<input type="text" name="price" value="$in{'price'}">
</P>
<input type="submit">
</form>
</body>
</html>
PrintTag
exit(0);
}
if ($in{'password'} ne "test"
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H1>Sorry, Charlie!</H1>
<BLOCKQUOTE>
I am sorry, but you do not have permission to modify this database.
</BLOCKQUOTE>
</BODY>
</HTML>
PrintTag
exit(0);
}
if (-e "lock.fil"
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>File in use</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H1>Try again!</H1>
<BLOCKQUOTE>
The database is in use. Please try again later.
</BLOCKQUOTE>
</BODY>
</HTML>
PrintTag
exit(0);
}
#everything is okay. Create lock file.
open(LOCK_FILE, ">lock.fil"
;
#open, append record, and close database
open(FILE,">>data.txt"
|| die "Can't find database\n";
print FILE "$in{'year'}|$in{'winery'}|$in{'wine'}|$in{'price'}\n";
close(FILE);
#close lock file
close(LOCK_FILE);
#delete lock file
unlink("lock.fil"
;
#print database contents
print "Location: #end of program
#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse;
#remove '$' character from price field
$in{'price'} =~ s/\$//g;
if ($in{'password'}eq"" || $in{'year'}eq"" || $in{'winery'}eq"" || $in{'wine'}eq"" || $in{'price'}eq""
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<form action=" method="POST">
<P>You forgot to fill in one or more of the fields below. Please try again.</P>
<P>Password: <BR>
<input type="password" name="password" value="$in{'password'}"></P>
<P>Year: <BR>
<input type="text" name="year" value="$in{'year'}">
</P>
<P>Winery:<BR>
<input type="text" name="winery" value="$in{'winery'}">
</P>
<P>Wine:<BR>
<input type="text" name="wine" value="$in{'wine'}">
</P>
<P>Price:<BR>
<input type="text" name="price" value="$in{'price'}">
</P>
<input type="submit">
</form>
</body>
</html>
PrintTag
exit(0);
}
if ($in{'password'} ne "test"
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>Error!</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H1>Sorry, Charlie!</H1>
<BLOCKQUOTE>
I am sorry, but you do not have permission to modify this database.
</BLOCKQUOTE>
</BODY>
</HTML>
PrintTag
exit(0);
}
if (-e "lock.fil"
{
print &PrintHeader;
print <<"PrintTag";
<HTML>
<HEAD>
<TITLE>File in use</TITLE>
</HEAD>
<BODY BGCOLOR="white" TEXT="black">
<H1>Try again!</H1>
<BLOCKQUOTE>
The database is in use. Please try again later.
</BLOCKQUOTE>
</BODY>
</HTML>
PrintTag
exit(0);
}
#everything is okay. Create lock file.
open(LOCK_FILE, ">lock.fil"
#open, append record, and close database
open(FILE,">>data.txt"
print FILE "$in{'year'}|$in{'winery'}|$in{'wine'}|$in{'price'}\n";
close(FILE);
#close lock file
close(LOCK_FILE);
#delete lock file
unlink("lock.fil"
#print database contents
print "Location: #end of program