Also note, that i am not too bothered about the e-mail address validation.#!/usr/bin/perl -wT use CGI; use strict; # Set Variables my $w = new CGI; my $ip = $ENV{'REMOTE_ADDR'}; my $message = ""; my $found_err = ""; my $filenum = time.int rand 1000000; # Grab Input From Form my $username = $w->param('username'); my $domain = $w->param('domain'); my $email = $w->param('email'); my $service = $w->param('service'); my $conditions = $w->param('conditions'); # Begin Sanitising Input if ($username !~ /^[A-Za-z][-.\w]{2,29}$/) { $message = $message."<p>Error With Username. Please Retry</p>\ +n"; $found_err = 1; } if ($domain !~ m/^a.com|c.com|f.com|h.net|ho.com| |i.com|k.com|o.com|s.com|x.com$/) { $message = $message."<p>Error With Domain. Contact Support</p> +\n"; $found_err = 1; } if ($email !~ /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9] +)+$/i) { $message = $message."<p>Error With E-Mail Address. Please Retry</p +>\n"; $found_err = 1; } if ($service !~ m/^Yes|No$/) { $message = $message."<p>Error With Service. Contact Support</p +>\n"; $found_err = 1; } if ($conditions !~ m/^Yes$/) { $message = $message."<p>Please Accept The Terms And Conditions +</p>\n"; $found_err = 1; } if ($found_err) { &PrintError; } # Dump User Data To File open (LOGFILE, ">>/var/log/accounts/$filenum") or die $!; print LOGFILE "$username,$domain,$email,$service,$ip\n"; close (LOGFILE); # Display Html Completion print "Content-type: text/html\n\n"; print "Blah Blah, All Done\n"; # Display Error Messages sub PrintError { print "Content-type: text/html\n\n"; print $message; exit 0; return 1; }
In reply to Peruse my code... by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |