howarda has asked for the wisdom of the Perl Monks concerning the following question:
#!C:\Perl\bin\perl.exe -wT use strict; use DBI; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser/; my $tainted_mpan = param( 'mpan' ) || ''; my $tainted_date = param( 'date' ) || ''; my $mpan = ''; my $dd=''; my $mm=''; my $yy=''; my $message = 'The MPAN you have entered is not valid. Please re-enter +'; my $message1="Invalid MPAN"; my $message2="Invalid Date"; #check that the mpan is in the correct format #it may not exist but it has to be 13 numbers if ( $tainted_mpan =~ /^(\d{13})$/ ) { $mpan = $1; #display_page($message2); }else{ display_page( $message1 ); exit; } #check that the date format is correct DD/MM/YY if ( $tainted_date =~ /^(\d{2})\/(\d{2})\/(\d{2})/) { $dd=$1; $mm=$2; $yy=$3; search_mpan(); }else{ display_page($message2); exit; } #routine to display any messages generated sub display_page { my $message = shift; print header, start_html, p( $message ), end_html; } sub search_mpan { my @rows; my $dbh = DBI->connect('dbi:ODBC:database.server',"username", "pas +sword") or display_page("$DBI::errstr"); display_page("This worked"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI and DBI
by hmerrill (Friar) on Nov 29, 2004 at 12:29 UTC | |
|
Re: CGI and DBI
by castaway (Parson) on Nov 29, 2004 at 13:17 UTC | |
by howarda (Acolyte) on Nov 29, 2004 at 15:44 UTC | |
by hmerrill (Friar) on Nov 29, 2004 at 19:35 UTC | |
by howarda (Acolyte) on Nov 30, 2004 at 09:38 UTC | |
by hmerrill (Friar) on Dec 02, 2004 at 12:57 UTC | |
|
Re: CGI and DBI
by htoug (Deacon) on Nov 29, 2004 at 13:09 UTC |