Changeset 27


Ignore:
Timestamp:
Oct 12, 2006, 7:19:51 PM (13 years ago)
Author:
Dominic Hargreaves
Message:

Add check for duplicate submissions.

File:
1 edited

Legend:

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

    r26 r27  
    6565}
    6666
     67# Check for a duplicate.
     68# We want to collect duplicates from different IP addresses as a kind of
     69# corroboration factor; this just catches accidental double-submission
     70# really.
     71$sth = $dbh->prepare('SELECT * FROM postcodes WHERE raw_postcode = ? AND easting = ? AND northing = ? AND ip = ?');
     72unless ($sth->execute($raw_postcode, $easting, $northing, $ENV{'REMOTE_ADDR'})) {
     73    print_err('Database error when checking for duplicate data :(');
     74}
     75
     76if ($sth->rows) {
     77    print_err('You, or someone with the same IP address, have already submitted this postcode with these co-ordinates.');
     78}
     79
    6780$sth = $dbh->prepare('INSERT INTO postcodes (outward, inward, raw_postcode, easting, northing, ip, created_at, source) VALUES (?, ?, ?, ?, ?, ?, ?, 0)');
    6881if ($sth->execute($outward, $inward, $raw_postcode, $easting, $northing, $ENV{'REMOTE_ADDR'}, time2str('%Y-%m-%d %H:%M:%S', time))) {
Note: See TracChangeset for help on using the changeset viewer.