The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
![]() |
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. ![]() - 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. ![]() - 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); 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 |