in reply to Newbie needs help with email CGI script

kilinrax is absolutely correct about not using cgi-lib.pl. Many CGI books still recommend this library, but it is out of date and no longer being maintained. In addition to his above comments, I would strongly suggest that you use taint checking. This script does not appear to actually need it, but as you write more and more scripts, you will need it to protect the integrity of your site. See perlsec for more details.

Your regex for testing for a valid e-mail address does not work. Below is a snippet explaining the use of Email::Valid. Email::Valid cannot catch all valid e-mail addresses as RFC822 allows for arbitrarily nested comments in e-mail addresses, but will probably correctly identify 99% or more of the e-mail addresses submitted.

#!/usr/bin/perl -wT use strict; use CGI; use Email::Valid; my $cgi = CGI-new(); my $email = $cgi->param( 'visitors_email_address' ); my $password = $cgi->param( 'visitor_password' ); my $valid_address = Email::Valid->address( $e-mail ); if ( $valid_address ) { # Address is valid, do stuff here # This DOES NOT mean that the address is real } else { # Address is invalid. }
Additionally, I noticed that you are not consistently checking the return calls on your open statements. If one fails to open, your script will silently continue and you won't know why.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just go the the link and check out our stats.