The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(257) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/printthread.php(257) : eval()'d code 2 errorHandler->error
/printthread.php 257 eval
/printthread.php 117 printthread_multipage
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
PHP Validation: check if value exists in mysql db - Printable Version

+- Form Tools (https://forums.formtools.org)
+-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1)
+--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5)
+--- Thread: PHP Validation: check if value exists in mysql db (/showthread.php?tid=751)

Pages: 1 2


PHP Validation: check if value exists in mysql db - Hannes - Jun 19th, 2010

Hi,

is there a way to check if a value exists in a mysql database an post a validation error if not?

br,
Hannes


RE: PHP Validation: check if value exists in mysql db - Ben - Jun 19th, 2010

Hi Hannes,

Sure - you'll need to use the following API function:
http://docs.formtools.org/api/?page=ft_api_check_submission_is_unique

That lets you query a form's database table to find out if a value already exists. It's pretty versatile, so it should work in your case.

All the best -

Ben


RE: PHP Validation: check if value exists in mysql db - Hannes - Jul 18th, 2010

Hi Ben,

thank you for your help. Unfortunatly I still did not get it running.

What I want to have is a user and a password field in the form.
Now the validation should check if user and password are matching in a mysql table cotaining the rows user and password.
Otherwise the error "user/password not matching" should appear.

Could you please give me a hint how this works with you API function?

Thanks a lot.
Hannes.


RE: PHP Validation: check if value exists in mysql db - Ben - Jul 20th, 2010

Hi Hannes,

Sure - no worries. I'm going to put together a tutorial for you. Give me a day or two at most - I'll post back then!

- Ben


RE: PHP Validation: check if value exists in mysql db - Hannes - Jul 31st, 2010

Hi Ben,

thank you a lot for your effort.
I'm looking forward very much for this tutorial.
Please let me know as soon you have a solution for me.

Best regards,
Hannes


RE: PHP Validation: check if value exists in mysql db - Ben - Aug 3rd, 2010

Hi Hannes,

Ack - sorry, I forgot about this.

I just wrote "Tutorial: check for uniqueness" on my whiteboard in capital letters. I'll get to it this week. Smile

- Ben


RE: PHP Validation: check if value exists in mysql db - Hannes - Aug 8th, 2010

Hi Ben,

Can't wait! I hope you will find the time to get it finished this week.

Hannes.


RE: PHP Validation: check if value exists in mysql db - Ben - Aug 14th, 2010

Hi Hannes,

I *am* sorry for the wait! I just finished it off:
http://docs.formtools.org/tutorials/checking_for_uniqueness/

Hopefully it makes sense, but let me know if I'm not clear on anything. Smile

- Ben


RE: PHP Validation: check if value exists in mysql db - Hannes - Aug 15th, 2010

Yehaw! Thanks a lot...

Did I understand correct:
If I have a form 1 with...
PHP Code:
$fields ft_api_init_form_page(1);
...
"A"  => $_POST["B"]
);
if (!
ft_api_check_submission_is_unique(2$criteria$fields["form_tools_submission_id"]))
... 
the function will check if the posted form field "B" in form 1 already exists in column "A" of form 2?


RE: PHP Validation: check if value exists in mysql db - Ben - Aug 16th, 2010

Quote:the function will check if the posted form field "B" in form 1 already exists in column "A" of form 2?

Precisely. And note that "A" is the database column name - not the form field name. That one always trips me up.

(Just one thing: in this scenario, make sure the first parameter of ft_api_check_submission_is_unique is 1, not 2 - that should be your form ID).

- Ben