#!/usr/bin/perl -w use CGI':standard'; use CGI::Carp "fatalsToBrowser"; use DBI; sub err() {print "Error in @_[0] field - @_[1]"; print "
";exit;} print header; print " "; $PRICE=param('PRICE');$BEDROOMS=param('BEDROOMS'); $COMMENTS=param('COMMENTS');$LOCATION=param('LOCATION'); $PROPTYPE=param('PROPTYPE');$NAME=param('NAME'); $TELEPHONE=param('TELEPHONE');$EMAIL=param('EMAIL'); if(($PRICE !~ /\A\d+\Z/) || ($PRICE>1000000 || $PRICE<0)){&err("PRICE",$PRICE);} if(($BEDROOMS !~ m/\A\d+\Z/) || ($BEDROOMS>10 || $BEDROOMS<1)){&err("BEDROOMS",$BEDROOMS);} if($COMMENTS !~ m/\w|/){&err("COMMENTS",$COMMENTS);} if($LOCATION !~ m/London|Manchester|Coventry|Leeds/i ){&err("LOCATION",$LOCATION);} if($PROPTYPE !~ m/Freehold|Leasehold/i ){&err("PROPTYPE",$PROPTYPE);} if($NAME !~/\A[a-z]+\Z/i){&err("NAME",$NAME);} if($TELEPHONE !~ m/\A\d+\Z/i){&err("TELEPHONE",$TELEPHONE);} if($EMAIL !~/\A[a-z]+\@[a-z]+\Z/i){&err("EMAIL",$EMAIL);} if($PROPTYPE eq "FREEHOLD"){$PROPTYPE="F"}; if($PROPTYPE eq "LEASEHOLD"){$PROPTYPE="L"}; print "Price | Bedrooms | Comments |
£ $result[0] | $result[1] | $result[2] | \n"; } print "