- Timestamp:
- Oct 17, 2006, 5:53:17 PM (15 years ago)
- Location:
- trunk/npemap.org.uk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/npemap.org.uk/cgi/submit.fcgi
r71 r72 24 24 setup_dbh(); 25 25 26 27 my @fields = qw(easting northing postcode); 26 my @fields = qw(easting northing postcode1 postcode2); 28 27 my $returnBaseURL = ''; 29 28 … … 80 79 81 80 # Now validate the postcode input format 82 my $raw_postcode = $cgi->param('postcode'); 81 my $raw_postcode = $cgi->param('postcode1'); 82 $raw_postcode .= ' ' . $cgi->param('postcode2') if defined $cgi->param('postcode2'); 83 83 my $trimmed_postcode = $raw_postcode; 84 84 $trimmed_postcode =~ s/^\s+//; … … 108 108 # corroboration factor; this just catches accidental double-submission 109 109 # really. 110 $sth = $dbh->prepare('SELECT raw_postcode FROM postcodes WHERE raw_postcode= ? AND easting = ? AND northing = ? AND ip = ?');111 unless ($sth->execute($ raw_postcode, $easting, $northing, $ENV{'REMOTE_ADDR'})) {110 $sth = $dbh->prepare('SELECT raw_postcode_outward FROM postcodes WHERE raw_postcode_outward = ? AND raw_postcode_inward = ? AND easting = ? AND northing = ? AND ip = ?'); 111 unless ($sth->execute($cgi->param('postcode1'), $cgi->param('postcode2'), $easting, $northing, $ENV{'REMOTE_ADDR'})) { 112 112 print_err('Database error when checking for duplicate data :(', $returnlink); 113 113 next REQUEST; … … 119 119 } 120 120 121 $sth = $dbh->prepare('INSERT INTO postcodes (outward, inward, raw_postcode , easting, northing, ip, source) VALUES (?, ?, ?, ?, ?, ?, 0)');122 if ($sth->execute($outward, $inward, $ raw_postcode, $easting, $northing, $ENV{'REMOTE_ADDR'})) {121 $sth = $dbh->prepare('INSERT INTO postcodes (outward, inward, raw_postcode_outward, raw_postcode_inward, easting, northing, ip, source) VALUES (?, ?, ?, ?, ?, ?, ?, 0)'); 122 if ($sth->execute($outward, $inward, $cgi->param('postcode1'), $cgi->param('postcode2'), $easting, $northing, $ENV{'REMOTE_ADDR'})) { 123 123 print "Content-type: text/html\n\n"; 124 124 print "<html><head><title>Thank you</title></head>\n"; -
trunk/npemap.org.uk/schema_postgres.sql
r62 r72 23 23 outward character varying(5) NOT NULL, 24 24 inward character varying(3), 25 raw_postcode character varying(30) NOT NULL, 25 raw_postcode_outward character varying(30) NOT NULL, 26 raw_postcode_inward character varying(30), 26 27 easting integer NOT NULL, 27 28 northing integer NOT NULL,
Note: See TracChangeset
for help on using the changeset viewer.