Gossamer Forum
Home : Products : Gossamer Links : Discussions :

add.cgi: check field value in links table

Quote Reply
add.cgi: check field value in links table
Hi,

I've modified add.cgi to use a unique identifier tag 'Rcpt' (passed as add.cgi?Rcpt=xxxxxx) to put in field 'rcpt' and it works fine, but I've found that someone can go back and re-use the form to submit another entry with the same rcpt reference - I don't want that.

I'd like add.cgi to check the currect links database for 'rcpt' and report an error if it finds and existing entry with the same rcpt reference (this is to stop them using the form for more than one submission.)

I've setup the error reporting and checking for the presence of 'rcpt', so now I just need a code snippet to check the links.

In my v1.13 I have the duplicate URL check that uses $db->query and $db->hits to establish if the input for 'URL' exists, but it doesn't appear to work the same for 2.x

Here's what I'm using:

Code:
# Check for duplicate rcpt in links

my $chk_rcp = $db->query ( { rcpt => $IN->param('rcpt') } );

if ($chk_rcp) {
print $IN->header();
print Links::SiteHTML::display('error', { error => Links::language('DUP_RCPT')});
exit;
}
... but this returns the error every time.

Firstly, have I got the query right?
Secondly, how would I check for 'hits'?

Any help appreciated Smile

All the best
Shaun

Quote Reply
Re: add.cgi: check field value in links table In reply to
try this:
my $chk_rcp = $db->count ( { rcpt => $IN->param('rcpt') } );
if ($chk_rcp) {
print ......
}


Quote Reply
Re: add.cgi: check field value in links table In reply to
Thanks - that seems to work fine Smile

All the best
Shaun

Quote Reply
Re: add.cgi: check field value in links table In reply to
And it's a little better as query() defaults to a LIKE '%term%' match so if you have 'foobar' in your Rcpt column, the 'foo' would match. count() will do an exact match.

Cheers,

Alex

--
Gossamer Threads Inc.