Help for comparing data between input and databas

Hello,

I’ve already searched the forum history but I didn’t find a good answer for now. I tried some things, but didn’t succeed. Here is what I want to do :

I want the user to input the answer to a question in an input field. If it is the right answer, then I will do some action.

I already created a data in my database, but I don’t know how to compare the input data to the data in the database. And tell the user if he’s right or not.

Thank you !!

Assuming you’re allowing your users to type their answer directly into an input (as opposed to selecting from a multiple choice), then you’ll simply want to compare the input to the database, as you say…

You can find a full list of operators and comparisons in the Bubble manual: Operators & Comparisons - Bubble Docs.

In the most simple terms you could just use Input's Value is Question's Answer, but things will be much more complicated than that in reality…

You’ll need to account for things like capitalization, variations on spelling, phrasing, punctuation, and typos etc…

So you’ll probably want to store a list of acceptable answers in the database for each question (all in a particular case), convert the input values into that same case, ignore punctuation or extra spaces - things like that.

So the standard Bubble operators should probably be ok (you might need some regex too depending on the complexity of the answers).

Thank you for your quick answer !

When I say user, I’m no talking about a connected user. Anyone, connected or not (actually, I don’t have a user database with a connexion option for now) will be able to input text in the field and “send” it.

And for the answer, for this precise example, I actually need a perfectly spelled answer. Like a password.

Anyone who uses your app is a User (regardless of whether hey are registered or not). In any case that doesn’t matter here…

And for the answer, for this precise example, I actually need a perfectly spelled answer. Like a password.

In that case it’s simple, you can just match the input exactly to the database value - just use ‘Is’ as the comparison.

1 Like

Thank you !

But there is something I don’t get. Here is what I’ve done :
When the user click on “send” button, I set a workflow for another group to appear. Only when “input” value is ???
I don’t have an option to choose the data in database. Am I doing something wrong here ?

Unless you’ve loaded the data somewhere on the page that you can refer to, you’ll have to do a search to find the specific data you need from the database…

So only when Input's value is: do a search for and then find the data you need to check it against, and then refer to the specific text field on that database entry.

1 Like

Ok I’m starting to understand how it works ! I will try to work on it tonight.

Thank you again, and I’ll keep you informed

1 Like

Hi @frederic.borensztein … I’m glad that your issue seems to have been resolved thank to @adamhholmes. For any future reference, it always helps to share screenshots of your workflows that need a look. This can speed up the assistance too, less communication needed to understand the issue at hand :slight_smile: Cheers.

@deejay.shani Yes of course ! I’ll dot it from now on :slight_smile:
@adamhholmes I’m sorry to bothering you again, but I’m stuck again :frowning:
bubble_screen_2

First screenshot is my design obviously.
“Input PW PUZZLE2” is the input field
“puzzle1_password” is the value is the entry in my database

I tried all options for “sort by”, but it doesn’t work. Maybe I did something wrong here…

I also tried to use another logic, using a custom state that changes when the right password is sent. To allow me to do another action with this custom state change. But it is the same issue, I can’t get to “compare” the two values…

1 Like

You need to specify which puzze1_password entry you’re comparing it to, by adding search constraints to match fields on the datatype.

The search will always return a list (even if there’s only one item in the list), so you’ll then need to specify First Item to select the first (and only) item from the list.

Then back in the only when box, select the field from the data type that you’re comparing the input’s value to.

I’m almost there I guess.
I totally understand the logic > search my entry using constraints fields. As I only have 1 entry in the list, I specify first item (which I did).
But I’m obviously missing something here.

EDIT : I used the already created “THING” entry. And using the “name” value, it worked !
So everything is find, even if I have to dig a little more to understand every details of it. But for now I am good I think. Thank you very much for your help !!!

2 Likes

If it’s only one entry (like a password to enter the app etc.), then you do not need to create a thing for this. You can simply say ONLY WHEN: Input PW PUZZLES2’s value is" and then just type the password and click outside the box to end the equation :slight_smile: This method may work best if you have one or just a handful entries (like up to 10 maybe?)

Indeed, it’s perfect for what I need.

But now, Bubble database logic is crystal clear for me, so it will be great for future features !

Thanks