I hope someone can help me out.

I set up this cgi file and html form on a Unix server. The script
changes a user's password in a text file.

This works correctly on a Unix Server. However, I need to move these
files to an IIS server.
In testing on the IIS server,  I get an HTTP Error 405- Method not
allowed when the form is submitted. 

I did some research, but was unable to determine how to correct the
error. 

If anyone could help me out, I'd really appreciate it.

Thanks, Maureen

#!/usr/bin/perl
require "cgi-lib.pl";
#process incoming form data 
&ReadParse;
#set content type
print &PrintHeader;
#initialize variables
$pwfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.txt";
$tmpfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.tmp";
$lokfile =
"/data1/hypermart.net/worldwidewebstrategies/datafile/pwlock.fil";
#Print initial tags for web page
print "<HTML><BODY>\n";
#check for existence of password file
unless (-e $pwfile)
{ 
#password file doesn't exist!
#print message & shut down
print <<"PrintTag";
<H1>Sorry!</H1>
<P>$pwfile has't been uploaded to the
proper directory. Please contact the webmaster.</P>
</BODY>
</HTML>
PrintTag
exit(0);
}
#check for blank form fields
if ($in{'oldname'}eq"" || $in{'oldpw'}eq"")
{
#re-create form and shut down program
print <<"PrintTag";
<P><B>ERROR:</B> Please type your current username and
password in the spaces provided.</P>
<FORM
ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changepw.cgi";
METHOD="post">
<P>Your current username:<BR>
<INPUT TYPE="text" NAME="oldname" VALUE="$in{'oldname'}"></P>
<P>Your current password:<BR>
<INPUT TYPE="text"NAME="oldpw" VALUE="$in{'oldpw'}"></P>
<P>Your new password:<BR>
<INPUT TYPE="text" NAME="newpw1" VALUE="$in{'newpw1'}"></P>
<P>Type your new password again:<BR>
<INPUT TYPE="text" NAME="newpw2" VALUE="$in{'newpw2'}"></P>
<P>
PrintTag
if ($in{'delete'} eq "yes")
{
print "<INPUT TYPE=\"checkbox\" 
NAME=\"delete\" VALUE=\"yes\" CHECKED>\n";
}
else
{
print "\n";
}
print <<"PrintTag";
</P>
<INPUT TYPE="submit" VALUE="Change">
</FORM>
</BODY>
</HTML>
PrintTag
exit(0);  
} 
#make sure new passwords match 
if ($in{'newpw1'} ne $in{'newpw2'})
{ 
#re-create form and shut down program  
print <<"PrintTag";
<P><B>ERROR:</B> Your new passwords didn't match. 
You must type your new password exactly the same way twice. 
Please try again.</P>
<FORM
ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changepw.cgi";
METHOD="post">
<P>Your current username:<BR>
<INPUT TYPE="text" NAME="oldname" VALUE="$in{'oldname'}"></P>
<P>Your current password:<BR>
<INPUT TYPE="text" NAME="oldpw" VALUE="$in{'oldpw'}"></P>
<P>Your new password:<BR>
<INPUT TYPE="text" NAME="newpw1"></P>
<P>Type your new password again:<BR>
<INPUT TYPE="text" NAME="newpw2"></P>
<INPUT TYPE="submit" VALUE="Change">
</FORM>
</BODY>
</HTML>
PrintTag
exit(0);  
}
#check for existence of lock file  
if (-e $lokfile)   
{ 
#lock file exists! print message & shut down   
print <<"PrintTag";
<H1>Try again!</H1>  
<P>The database is in use. Please try again later.</P>  
</BODY>  
</HTML>  
PrintTag
exit(0);  
} 
#everything is okay. Create lock file.  
open(LOCK_FILE, ">$lokfile") || 
die "Couldn't create $lokfile\n";
#open password file in read-only mode 
open(FILE,"$pwfile") || 
die "Can't find $pwfile.\n"; 
#store database contents in an array and close file
@indata = <FILE>;
close(FILE);
#open temp file in overwrite mode 
open(TEMP,">$tmpfile") || 
die "Can't create $tmpfile.\n"; 
#copy password file contents to temp file 
#use a foreach loop to process each record in the array
foreach $i (@indata)
{
#remove hard return character from each record
chomp($i);
#split fields on pipe character
#assign a variable name to each of the fields
($username,$password) = split(/\|/,$i);
if ($username eq $in{'oldname'} && 
$password eq $in{'oldpw'} && 
$in{'delete'} ne "yes")
{
print TEMP "$in{'oldname'}|$in{'newpw1'}\n";   
print "<P><h1> Success!</h1>Your password has been changed.</P>\n";
}
elsif ($username eq $in{'oldname'} && 
$in{'delete'} eq "yes")
{
print "<P>Your password has been deleted.</P>\n";
}
else
{
print TEMP "$i\n";
}
} 
#close temp file 
close(TEMP);
#change file names 
rename($pwfile, $pwfile.".old"); 
rename($tmpfile, $pwfile); 
#close and delete lock file 
close(LOCK_FILE); 
unlink($lokfile);
#close web page
print "<P>Thank you! </P>\n";
print "</BODY></HTML>\n";
#end of script

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to