use strict; use diagnostics; use warnings; use CGI; my $q = new CGI; my $user_name = $q->param('user_name') || ''; my $gender = $q->param('gender') || ''; my $real_name = $q->param('real_name') || ''; my $city = $q->param('city') || ''; my $country = $q->param('country') || ''; my $email = $q->param('email') || ''; my $confirmemail= $q->param('confirmemail') || ''; my $mm = $q->param('birthmm') || ''; my $dd = $q->param('birthdd') || ''; my $yy = $q->param('birthyy') || ''; my ($title, $body, $i, $s, @v, @c); my $file = 'c:/test.file'; #--------------------------------------------------------------------- #START OF MAIN PROGRAM #--------------------------------------------------------------------- my $password = password(5); my $dateofbirth = "$dd/$mm/$yy"; my @info = ($user_name, $password, $email, $gender, $real_name, $dateofbirth, $city, $country); if ($email ne $confirmemail){ ($title, $body) = &email_invalid(); } elsif (&check_user_email($user_name,$email) eq "good"){ ($title, $body) = &good(@info); } else { ($title, $body) = &check_user_email($user_name,$email); } print qq(Content-type: text/html\n $title $body ); #--------------------------------------------------------------------- #END OF MAIN PROGRAM:BEGINING OF VERIFICATION #--------------------------------------------------------------------- sub email_invalid { my $title = "Email's do not match!!"; my $body = q(

Your e-mail doesn't match.



Please click on your browsers back button and try again.


); return ($title, $body); } #--------------------------------------------------------------------- sub check_user_email{ my ( $user, $email ) = @_; open USRNF, $file or die "Couldn't find user file $file, Perl says $!\n"; # generate a lookup hash from the file while() { chomp; my @userinfo = split /\t/, $_; next unless $userinfo[0] and $userinfo[2]; $hash{$userinfo[0]} = $userinfo[2]; } close USRNF; if ( exists $hash{$user} ){ # username exists, two posibilities if ( $hash{$user} eq $email ) { my $title = "Account already activated.!"; my $body = qq|

Our records show that you already have a valid account.



If you wish to create another one you must first delete the old one.

Please email me here to edit any account info.
|; return $title, $body; } else { my $title = "User name already in use!"; my $body = qq|

The username $user is already in use.



Please click on your browser's back button and try a different one.


|; return $title, $body; } } # if we have not returned by here then the username is unique so... return 'good'; } #--------------------------------------------------------------------- sub good { my @info = @_; my $title = "Registration successful!"; my $revised = scalar localtime; my $body = <

Registration Confirmation


Dear, $real_name

Thank you for registering with us. You have supplied us with the following information:

Real name:\t$real_name
Username:\t$user_name
Password:\t$password
E-mail:\t$email
Date of Birth:\t$dateofbirth
City:\t$city
Country:\t$country

If any of this information is incorrect, please email me here to change it. I reserve the right to delete any user if he/she use this account for illegal purposes.

Sincerely,

Webmaster, Eoin.


You may return to the feedback form by using the Back button in your browser.
Revised: $revised
HTML open USRNF,">>$file" or die "Couldn't find user file $file, Perl says $!\n"; print USRNF join "\t", @info; print USRNF "\n"; close USRNF; return $title, $body; } sub password{ my $s = shift; srand($s ^ time); @c = split //, "bcdfghjklmnpqrstvwxyz"; @v = split //, "aeiou"; my $password = ''; $password .= $c[int(rand(21))] .$v[int(rand(5))] for 1..4; return $password; }