Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Can registration verify multiple dblookup fields?

  • erichf
  • erichf
  • OFFLINE
  • Posts: 50
  • Thanks: 6
  • Karma: 1
11 years 4 months ago #228997 by erichf
Our site services a private community. IN order to register for the site, they have to provide a couple of pieces of information that we then need to verify to ensure that they are allowed to join the community.

For example, assume that they have to provide their street and street number to register. We have a database of the streets and street numbers that are allowed to register.

The dblookup plug-in allows us to do a field verification using one field variable so that it would work with a statement like:

SELECT * `allowed_houses` WHERE `street` = '[value]'

This SQL query check field will verify that the street field that the user included in the registration field matches one of the street fields in the database. However, we want to verify that they live on specific streets in specific houses, so we want to have a query like:

SELECT * `allowed_houses` WHERE '`street` = '[value]' AND `street_number_field` = 'street_number_in_database'

Is this possible? Is there another way to accomplish the same objective of verifying a combination of fields?

Thanks

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
11 years 4 months ago #229012 by nant

erichf wrote:
This SQL query check field will verify that the street field that the user included in the registration field matches one of the street fields in the database. However, we want to verify that they live on specific streets in specific houses, so we want to have a query like:

SELECT * `allowed_houses` WHERE '`street` = '[value]' AND `street_number_field` = 'street_number_in_database'

Is this possible? Is there another way to accomplish the same objective of verifying a combination of fields?

Thanks


Sure, this is doable - did you try this?
Test your sql in phpmyadmin to make sure it is valid first and it works.

Please Log in or Create an account to join the conversation.

  • erichf
  • erichf
  • OFFLINE
  • Posts: 50
  • Thanks: 6
  • Karma: 1
11 years 4 months ago #229019 by erichf
The SQL is fine with constants rather than variables.

SELECT * `allowed_houses` WHERE `street` = '[value]' AND `street_number` = '5'

The problem is that I don't know how to retrieve the variables from the registration form.

I tried:

SELECT * `allowed_houses` WHERE `street` = '[value]' AND `street_number` = '[cb_streetnumber]'

but [cb_streetnumber] doesn't seem to retrieve that field value from the form.

The objective of this to be able to confirm that there is an entry in the table that includes the street and street number combined.

Please Log in or Create an account to join the conversation.

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
11 years 4 months ago #229023 by nant
I think I understand now.

If you intend to split the address into 2 fields - cb_street and cb_number then you will most likely need 2 lookup fields.

I believe that you should also be able to do what you want with a single validation field.

Make sure that the lookup field is the second one on the form - this way the code will be able to use the substitution.

I will also do some tests locally and post back feedback.

Please Log in or Create an account to join the conversation.

  • erichf
  • erichf
  • OFFLINE
  • Posts: 50
  • Thanks: 6
  • Karma: 1
11 years 4 months ago #229825 by erichf
It looks like that fix addresses the problem. I tripped over the fact that the dblookup field has to come after the other fields being evaluated but once I got that correct, it works fine.

Is there a way to generate more meaningful error messages for the user other than the standard `field name: "Invalid Code"` message which is hard coded in dblookupfield.php? Can this be extracted out to a language file so it's not a core hack if we change that message?

Thanks

Erich

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum