Changeset 72


Ignore:
Timestamp:
Oct 17, 2006, 5:53:17 PM (13 years ago)
Author:
Dominic Hargreaves
Message:

Postcode input format is in two fields

Location:
trunk/npemap.org.uk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/npemap.org.uk/cgi/submit.fcgi

    r71 r72  
    2424setup_dbh();
    2525
    26 
    27 my @fields = qw(easting northing postcode);
     26my @fields = qw(easting northing postcode1 postcode2);
    2827my $returnBaseURL = '';
    2928
     
    8079
    8180    # 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');
    8383    my $trimmed_postcode = $raw_postcode;
    8484    $trimmed_postcode =~ s/^\s+//;
     
    108108    # corroboration factor; this just catches accidental double-submission
    109109    # 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'})) {
    112112        print_err('Database error when checking for duplicate data :(', $returnlink);
    113113        next REQUEST;
     
    119119    }
    120120
    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'})) {
    123123        print "Content-type: text/html\n\n";
    124124        print "<html><head><title>Thank you</title></head>\n";
  • trunk/npemap.org.uk/schema_postgres.sql

    r62 r72  
    2323    outward character varying(5) NOT NULL,
    2424    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),
    2627    easting integer NOT NULL,
    2728    northing integer NOT NULL,
Note: See TracChangeset for help on using the changeset viewer.