Re: I did it!!!
Hello Newbie, And let us not forget to scold you on your non-use of "strict". The use of it in this list will help avoid future flames & find errors in longer, more complex scripts. I'll demonstrate the use of it, & include the tips posted thus far... #!c:/perl/bin/perl -w use strict; my $number; my $mult; my $result; print "Enter a number: "; chomp($number = ); print "Enter a multiplier: "; chomp($mult = ); $result = $number * $mult; print "The result you ignorant fool is: $result\n"; ## OR ## #!c:/perl/bin/perl -w use strict; print "Enter a number: "; chomp(my $number = ); print "Enter a multiplier: "; chomp(my $mult = ); my $result = $number * $mult; print "The result, you ignorant fool, is: $result\n"; ## OR ## #!c:/perl/bin/perl -w use strict; my ($number,$mult,$result); print "Enter a number: "; chomp($number = ); print "Enter a multiplier: "; chomp($mult = ); $result = $number * $mult; print "The result, you ignorant fool, is: $result\n"; Thursday, July 05, 2001, 5:01:20 PM, you wrote: CS> Im sure I could get flamed for this, but I just successfully wrote my first CS> program! Yaaahhh! CS> ## perl CS> #!c:/perl/bin/perl -w CS> print STDOUT "Enter a number: "; CS> chop($number = ); CS> print STDOUT "Enter a multiplier: "; CS> chop($mult = ); CS> $result = $number * $mult; CS> print STDOUT "The result you ignorant fool is: $result\n"; CS> Cool, huh? Not gonna win any awards, but at least I know how to use STDIN CS> and STDOUT. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +===+ + "Inherently, each one of us has the substance + + within to achieve whatever our goals and dreams + + define. What is missing from each of us is the + + training, education, knowledge and insight to + + utilize what we already have." -- Mark Twain+ +===+
Re: CGI.pm and form validation
Hello Jim, I noticed a response telling you to use JavaScript to validate your form input. Personally I browse with my JavaScript turned off to avoid pop-up ads so I don't believe it is a good idea to try to validate information using it. Here is an excerpt from my Sams book that could help you with solving the problem: print_header; my $return=param("return_addr"); if (! defined $return or ! $return) { print "You must supply an e-mail address"; exit; } my $subject=param("subject"); if (! define $subject or ! $subject) { print "You must supply a subject; exit; } Of course you will still have to verify that the info is in the proper format yourself. But, I believe that by doing this way, you will be assured of ACTUALLY getting ALL the form data in the first place. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ Friday, July 13, 2001, 8:17:20 AM, you wrote: SJR> I've created a CGI program that asks a user to fill in a number of fields. SJR> I would like to validate that the required data is present and in correct SJR> format. SJR> A date, time, phone number, Ip Address etc. SJR> Obviously I could code a number of regex's, but I was wondering if there was SJR> a module or script SJR> that I could use along with CGI.pm. SJR> Any Suggestions ? SJR> Regards, SJR> JimBob -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Regex, Taint, Review
Hello All, I have a script to process an inquiry form.(go figure ;) Anyway, if someone could take a quick look and see if I'm missing anything obvious or see anything that would allow a breach in security, I would appreciate it. Particularly my regex filters may need a third eye to catch something because they still aggravate my brain tumor to figure out sometimes. Also, I'd like to turn on taint checking but I believe that my $ENV{'HTTP_REFERER'} & $ENV{REMOTE_ADDR} are the cause of errors when I do. If someone could show me how to fix this, I'll name my third born after you. Also, before anybody gets their panties in a bundle, I've read all the banter on this list about validating email addresses & how it can't be done 100% of the time, the mods to look at & such. I'm just shooting for a high 80% success. I got fred&[EMAIL PROTECTED] taken care of & the rest can read my error page telling them to just send me an e-mail with the info... ;) Code is below, thanks a bunch! #!/usr/bin/perl -w use strict; use CGI qw(:standard); $CGI::DISABLE_UPLOADS = 1; $CGI::POST_MAX= 512 * 1024; my ($ENV,$sendmail,$time,$name,$email,$subject,$comments, $bad_name,$bad_email,$bad_subject,$bad_comments); $sendmail = '/usr/sbin/sendmail'; $time = localtime(time); $bad_name = param('name'); if ( $bad_name =~ /^([a-zA-Z\s_]+)$/ ) { $name = $1; } else { error(); exit; } $bad_email = param('email'); if( $bad_email =~ m/\w\S+\@\w\S+\./) { $bad_email =~ /([\w+\-\&\._]+\@[\w+\.\-_]+)/; $email = $1; } else { error(); exit; } # A one-word drop-down menu selection for this one. If they try to # send anything else here... they can bite me ;) $bad_subject = param('subject'); if ( $bad_subject =~ /^([a-zA-Z]+)$/ ) { $subject = $1; } else { error(); exit; } $bad_comments = param('comments'); if ( $bad_comments =~ /^([a-zA-Z\d\s\-\.\?!,_]+)$/ ) { $comments = $1; } else { error(); exit; } if (($ENV{'HTTP_REFERER'} eq "http://www.my-domain.com/contact/index.html";) || ($ENV{'HTTP_REFERER'} eq "http://my-domain.com/contact/index.html";) || ($ENV{'HTTP_REFERER'} eq "http://www.my-domain.com/contact/";) || ($ENV{'HTTP_REFERER'} eq "http://my-domain.com/contact/";)) { # DO NADA - JUST CONTINUE ON } else { invalid(); exit; } if(param()) { open (MAIL, "| $sendmail -t -oi") || die "Can't open $sendmail : $!\n"; print MAIL "To: webmaster\@my-domain.com\n"; print MAIL "From: webmaster\@my-domain.com\n"; print MAIL "Subject: $subject\n\n"; print MAIL "On $time\n"; print MAIL "This information was received:\n\n"; ## Personal Information ## print MAIL "Inquiry Information:\n"; print MAIL "$ENV{REMOTE_ADDR}\n"; if($name) { print MAIL "Name: $name\n"; } else { error(); } if($email) { print MAIL "E-Mail: $email\n"; } else { error(); } if($subject) { print MAIL "Subject: $subject\n"; } else { error(); } if($comments) { print MAIL "Comments: $comments\n"; } else { error(); } close(MAIL); print "Location: http://www.my-domain.com/thankyou.html\n\n";; exit; } print "Location: http://www.my-domain.com/contact/index.html\n\n";; sub error { print "Location: http://www.my-domain.com/contact/error.html\n\n";; } sub invalid { print "Location: http://www.my-domain.com/contact/invalid.html\n\n";; } -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Off-Topic (200%) - Where are you from?
I'm from da UP, eh... Michigans' Upper Peninsula - The sun vacations here... sometimes. ;) Tuesday, November 13, 2001, 12:58:27 PM, you wrote: >From Alicante - SPAIN ( Mediterranean Coast ) The sun lives here... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Interpolate in Location:
Hello All, Could somebody please help me with this? print "Location: https://secure.whatever.com/business=email\@address.com\&item_name=Product+Name\&item_number=QX000\&amount=$total_amount\&shipping=0.00\&return=https://blah.com/ty.html\n\n";; I'm trying to interpolate the $total_amount in the above URL while escaping the other special characters. I've never tried to do this before & just can't wrap my ears around it now when I need to. If you feel this is a stupid/simple question... see my sig below... ;) If the above code is wrapped, sorry... my e-mail client _insisted_. Thank you in advance! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Interpolate in Location:
Hello Michael & List Members, Thanks for responding. Figured out the problem about 10 minutes after I sent the e-mail, turned out it was further up in the script where I assigned the value to this scaler. I know I got a bit escape-happy, but after banging my head on this for an hour I just started escaping everything that moved trying to find my stupidity... ;) Again, thanks for taking the time. Happy Holidays to all! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ Thursday, December 20, 2001, 2:58:46 PM, you wrote: MF> On Thu, Dec 20, 2001 at 04:33:57PM -0800, K.L. Hayes wrote: >> >> print "Location: >https://secure.whatever.com/business=email\@address.com\&item_name=Product+Name\&item_number=QX000\&amount=$total_amount\&shipping=0.00\&return=https://blah.com/ty.html\n\n";; >> >> >> I'm trying to interpolate the $total_amount in the above URL while >> escaping the other special characters. I've never tried to do this >> before & just can't wrap my ears around it now when I need to. MF> In what way isn't it working? Your code has no problem with it, and it MF> prints out what it should, as far as I can tell. You've escaped a bit too MF> much (the & don't need it), but that doesn't cause a problem. >> If the above code is wrapped, sorry... my e-mail client _insisted_. MF> It wasn't wrapped, though my mail viewer wrapped it. MF> Michael MF> -- MF> Administrator www.shoebox.net MF> Programmer, System Administrator www.gallanttech.com MF> -- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Interpolate in Location:
Hello Mr. Showalter, Friday, December 21, 2001, 7:14:40 AM, you wrote: BS> As Michael said, your code looks OK. The &'s don't need to be BS> escaped. BS> When you construct a URL, you should run it through URI::Escape's BS> uri_escape() method to encode any URI-special chars. Thanks for the advise on URI::Escape/method. I didn't know it existed until now. Also wanted to thank you for _ALL_ your "inadvertent" help over the last 4-5 months. I've got over 700 "Of Interest" mails saved from this list & most involve you & Japhy. Just want to let you know that your time, knowledge & patience is greatly appreciated. I wish you & yours, health & prosperity in the coming year. Thank you. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=====+ >> -Original Message- >> From: K.L. Hayes [mailto:[EMAIL PROTECTED]] >> Sent: Thursday, December 20, 2001 7:34 PM >> To: [EMAIL PROTECTED] >> Subject: Interpolate in Location: >> >> >> Hello All, >> >> Could somebody please help me with this? >> >> >> print "Location: >> https://secure.whatever.com/business=email\@address.com\&item_ >> name=Product+Name\&item_number=QX000\&amount=$total_amount\&sh >> ipping=0.00\&return=https://blah.com/ty.html\n\n";; >> >> >> I'm trying to interpolate the $total_amount in the above URL while >> escaping the other special characters. I've never tried to do this >> before & just can't wrap my ears around it now when I need to -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Should I use -e -d or opendir ?
Hello All, I've found lot's of info on how to check if a file exists but nothing about checking if a directory exists. I've posted the relevant code below along with 3 variations of how I "think" it might work. If somebody could point to the one that is "correct" or knows of a better way I'd appreciate the help. Thank you. use constant USER_PATH => '/home/~client/htdocs/clients/'; $path = USER_PATH . $personal_key; ## Is This Correct? ## if (-e "$path") { &get_on_with_it } else { &errorMsg } ## Or This? ## opendir(CLIENT, "$path") or die " &errorMsg "; closedir(CLIENT); &get_on_with_it ## Or Is It This? ## if (-d $path) { &get_on_with_it } else { &errorMsg } -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Should I use -e -d or opendir ?
Hello John, Thank you for responding. That's what I like most about this list. Ask a question, you usually end up getting a "buffet of answers" when all you could reasonably hope for was a "light snack". :) I appreciate your time & will keep your response for future reference as well. Hungry for knowledge, K.L. Hayes Wednesday, January 09, 2002, 8:17:23 PM, you wrote: JWK> "K.L. Hayes" wrote: >> >> Hello All, JWK> Hello, >> I've found lot's of info on how to check if a file exists but nothing >> about checking if a directory exists. I've posted the relevant code >> below along with 3 variations of how I "think" it might work. If >> somebody could point to the one that is "correct" or knows of a better >> way I'd appreciate the help. Thank you. JWK> No reason to "think" about it. Read the perlfunc documentation and JWK> write a small program to test it. JWK> $ perl -le' JWK> if (-f $ARGV[0]) {print "file"} else {print "NOT a file"} JWK> if (-d _) {print "directory"} else {print "NOT a directory"} JWK> if (-r _) {print "readable"} else {print "NOT readable"} JWK> if (-w _) {print "writable"} else {print "NOT writable"} JWK> if (-x _) {print "executable"} else {print "NOT executable"} JWK> if (-e _) {print "exists"} else {print "NOT exists"} JWK> if (-s _) {print "size"} else {print "NO size"} JWK> ' test.txt JWK> file JWK> NOT a directory JWK> readable JWK> writable JWK> NOT executable JWK> exists JWK> size JWK> $ perl -le' JWK> if (-f $ARGV[0]) {print "file"} else {print "NOT a file"} JWK> if (-d _) {print "directory"} else {print "NOT a directory"} JWK> if (-r _) {print "readable"} else {print "NOT readable"} JWK> if (-w _) {print "writable"} else {print "NOT writable"} JWK> if (-x _) {print "executable"} else {print "NOT executable"} JWK> if (-e _) {print "exists"} else {print "NOT exists"} JWK> if (-s _) {print "size"} else {print "NO size"} JWK> ' bin JWK> NOT a file JWK> directory JWK> readable JWK> writable JWK> executable JWK> exists JWK> size JWK> perldoc -f -X >> use constant USER_PATH => '/home/~client/htdocs/clients/'; >> $path = USER_PATH . $personal_key; >> >> ## Is This Correct? ## >> if (-e "$path") { >> &get_on_with_it } >> else { &errorMsg } >> >> ## Or This? ## >> opendir(CLIENT, "$path") or die " &errorMsg "; >> closedir(CLIENT); >> &get_on_with_it >> >> ## Or Is It This? ## >> if (-d $path) { >> &get_on_with_it } >> else { &errorMsg } JWK> The Perl motto is "There Is More Than One Way To Do It" :-) JWK> John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Won't write IP address to file
Hello All, Could somebody please help me figure out why the following code will not write the IP address to a file? I've verified that the code can find the file, open it & overwrite any junk/test data already there with nothing. I've also printed out the IP address on the previous page using just the print statement. sub pcheck { if (param('pwd') eq $pw ) { open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; flock (CHECK, 2) if ($flock); while () { print "$ENV{'REMOTE_ADDR'}"; } close (CHECK); flock (CHECK, 8) if ($flock); } else { &invalid_info; } &ad2; } All help is appreciated. Thank you for your time. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] +=+ + "Only two things are infinite, the universe and + + human stupidity, and I'm not sure about the former."+ + -- Albert Einstien + +=+ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Won't write IP address to file
Hello Robert, Duh! Thanks! I knew it was something stupid/simple. I just couldn't figure IT out AND be pulled in 20 other directions at the same time. Sometimes another eye planted in the middle of my forehead would really come in handy... *;) Thanks again for your time! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 12:32:06 PM, you wrote: HR> It looks like you forgot to specify the file handle when printing. HR> print CHECK "$ENV{'REMOTE_ADDR'}"; } HR> Rob HR> -----Original Message- HR> From: K.L. Hayes [mailto:[EMAIL PROTECTED]] HR> Sent: Wednesday, January 16, 2002 6:23 PM HR> To: [EMAIL PROTECTED] HR> Subject: Won't write IP address to file HR> Hello All, HR> Could somebody please help me figure out why the following code will HR> not write the IP address to a file? HR> I've verified that the code can find the file, open it & overwrite any HR> junk/test data already there with nothing. I've also printed out the HR> IP address on the previous page using just the print statement. HR> HR> sub pcheck { HR> if (param('pwd') eq $pw ) { HR> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; HR> flock (CHECK, 2) if ($flock); HR> while () { HR> print "$ENV{'REMOTE_ADDR'}"; } HR> close (CHECK); HR> flock (CHECK, 8) if ($flock); HR> } else { &invalid_info; } HR> &ad2; HR> } HR> HR> All help is appreciated. Thank you for your time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Won't write IP address to file
Hello Robert, After trying your advise it still didn't write to the file. Went & had some dinner... came back & it was obvious... Took the while () statement out & it worked like a charm. Whomever says that your stomach & brain aren't connected... is just wrong... in my case anyway... ;) Posted the solution in case anybody wanted to know. Thanks again! -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 12:32:06 PM, you wrote: HR> It looks like you forgot to specify the file handle when printing. HR> print CHECK "$ENV{'REMOTE_ADDR'}"; } HR> Rob HR> -Original Message- HR> From: K.L. Hayes [mailto:[EMAIL PROTECTED]] HR> Sent: Wednesday, January 16, 2002 6:23 PM HR> To: [EMAIL PROTECTED] HR> Subject: Won't write IP address to file HR> Hello All, HR> Could somebody please help me figure out why the following code will HR> not write the IP address to a file? HR> I've verified that the code can find the file, open it & overwrite any HR> junk/test data already there with nothing. I've also printed out the HR> IP address on the previous page using just the print statement. HR> HR> sub pcheck { HR> if (param('pwd') eq $pw ) { HR> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; HR> flock (CHECK, 2) if ($flock); HR> while () { HR> print "$ENV{'REMOTE_ADDR'}"; } HR> close (CHECK); HR> flock (CHECK, 8) if ($flock); HR> } else { &invalid_info; } HR> &ad2; HR> } HR> HR> All help is appreciated. Thank you for your time. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re[2]: Won't write IP address to file
Hello John, Just wanted to say Thank You for ripping my poor little code segment apart the way you did. Some might be offended if you did it to them, but not me... IT MAKES ME A BETTER PERL HACKER! :) Thanks for opening my eyes to some of my "stupid" code & enlightening me to some new ways of doing things. Since some of my reference material is a couple years old, I welcome the help in getting it right. In the future I'll make it a point to cross reference my books to perldoc to save everybody some time. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 2:12:13 PM, you wrote: JWK> "K.L. Hayes" wrote: >> >> Hello All, JWK> Hello, >> Could somebody please help me figure out why the following code will >> not write the IP address to a file? >> >> I've verified that the code can find the file, open it & overwrite any >> junk/test data already there with nothing. I've also printed out the >> IP address on the previous page using just the print statement. >> >> >> sub pcheck { >> if (param('pwd') eq $pw ) { >> open (CHECK,">${path}dmp.dat") || die "Cannot open dmp.dat: $!"; >> flock (CHECK, 2) if ($flock); JWK> use Fcntl ':flock'; JWK> if ( $flock ) { JWK> flock( CHECK, LOCK_EX ) or die "Cannot lock dmp.dat: $!"; JWK> } >> while () { JWK> You need this line only if you are reading data IN from a file, not JWK> writing OUT to a file. >> print "$ENV{'REMOTE_ADDR'}"; } JWK> print CHECK "$ENV{'REMOTE_ADDR'}"; >> close (CHECK); >> flock (CHECK, 8) if ($flock); JWK> There is no point in trying to unlock the file now, the close() has JWK> already unlocked it. >> } else { &invalid_info; } JWK> } else { invalid_info() } >> &ad2; JWK> ad2(); JWK> When you call subroutines you shouldn't use an ampersand unless you JWK> understand how and why it behaves differently. JWK> perldoc perlsub >> } >> >> >> All help is appreciated. Thank you for your time. JWK> John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Cgi on IIS
Hello Maureen, The only time I've seen the HTTP Error 405- when submitting a form is when I've inadvertently used action="post" instead of action="POST" which I see you've done in your script. I must have banged my head on that for over an hour before I figured it out. Hope this helps. -- Best regards, K.L. Hayes mailto:[EMAIL PROTECTED] Wednesday, January 16, 2002, 1:18:39 PM, you wrote: m> I hope someone can help me out. m> I set up this cgi file and html form on a Unix server. The script m> changes a user's password in a text file. m> This works correctly on a Unix Server. However, I need to move these m> files to an IIS server. m> In testing on the IIS server, I get an HTTP Error 405- Method not m> allowed when the form is submitted. m> I did some research, but was unable to determine how to correct the m> error. m> If anyone could help me out, I'd really appreciate it. m> Thanks, Maureen m> #!/usr/bin/perl m> require "cgi-lib.pl"; m> #process incoming form data m> &ReadParse; m> #set content type m> print &PrintHeader; m> #initialize variables m> $pwfile = m> "/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.txt"; m> $tmpfile = m> "/data1/hypermart.net/worldwidewebstrategies/datafile/pwdata.tmp"; m> $lokfile = m> "/data1/hypermart.net/worldwidewebstrategies/datafile/pwlock.fil"; m> #Print initial tags for web page m> print "\n"; m> #check for existence of password file m> unless (-e $pwfile) m> { m> #password file doesn't exist! m> #print message & shut down m> print <<"PrintTag"; m> Sorry! m> $pwfile has't been uploaded to the m> proper directory. Please contact the webmaster. m> m> m> PrintTag m> exit(0); m> } m> #check for blank form fields m> if ($in{'oldname'}eq"" || $in{'oldpw'}eq"") m> { m> #re-create form and shut down program m> print <<"PrintTag"; m> ERROR: Please type your current username and m> password in the spaces provided. m> ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changepw.cgi"; METHOD="post">> m> Your current username: m> m> Your current password: m> m> Your new password: m> m> Type your new password again: m> m> m> PrintTag m> if ($in{'delete'} eq "yes") m> { m> print " NAME=\"delete\" VALUE=\"yes\" CHECKED>\n"; m> } m> else m> { m> print "\n"; m> } m> print <<"PrintTag"; m> m> m> m> m> m> PrintTag m> exit(0); m> } m> #make sure new passwords match m> if ($in{'newpw1'} ne $in{'newpw2'}) m> { m> #re-create form and shut down program m> print <<"PrintTag"; m> ERROR: Your new passwords didn't match. m> You must type your new password exactly the same way twice. m> Please try again. m> ACTION="http://server37.hypermart.net/worldwidewebstrategies/cgi-bin/changepw.cgi"; METHOD="post">> m> Your current username: m> m> Your current password: m> m> Your new password: m> m> Type your new password again: m> m> m> m> m> m> PrintTag m> exit(0); m> } m> #check for existence of lock file m> if (-e $lokfile) m> { m> #lock file exists! print message & shut down m> print <<"PrintTag"; m> Try again! m> The database is in use. Please try again later. m> m> m> PrintTag m> exit(0); m> } m> #everything is okay. Create lock file. open(LOCK_FILE, ">>$lokfile") || m> die "Couldn't create $lokfile\n"; m> #open password file in read-only mode m> open(FILE,"$pwfile") || m> die "Can't find $pwfile.\n"; m> #store database contents in an array and close file m> @indata = ; m> close(FILE); m> #open temp file in overwrite mode open(TEMP,">>$tmpfile") || m> die "Can't create $tmpfile.\n"; m> #copy password file contents to temp file m> #use a foreach loop to process each record in the array m> foreach $i (@indata) m> { m> #remove hard return character from each record m> chomp($i); m> #split fields on pipe character m> #assign a variable name to each of the fields m> ($username,$password) = split(/\|/,$i); m> if ($username eq $in{'oldname'} && m> $password eq $in{'oldpw'} && m> $in{'delete'} ne "yes") m> { m> print TEMP "$in{'oldname'}|$in{'newpw1'}\n"; m> print " Success!Your password has been changed.\n"; m> } m> elsif ($username eq $in{'oldname'} && m> $in{'delete'} eq "yes") m> { m> print "Your password has been deleted.\n"; m> } m> else m> { m> print TEMP "$i\n"; m> } m> } m> #close temp file m> close(TEMP); m> #change file names m> rename($pwfile, $pwfile.".old"); m> rename($tmpfile, $pwfile); m> #close and delete lock file m> close(LOCK_FILE); m> unlink($lokfile); m> #close web page m> print "Thank you! \n"; m> print "\n"; m> #end of script -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]