Hello guys,
i have a strange problem with my registration function at the moment.
Everytime i register a person on the site via my formular, the information is put down twice into my database but the ID´s of those entries are different at least.
Any clues what i am doing wrong here?
Greetings, Dawd
Dawd
To search a database for records with multiple property values you effectively need to AND together query tests like .eq() and .gt(). These functions return a query as the result which can then be used to add subsequent tests.
So for example in your case you want to find a matching email and password. If the data collection is called "Members" then your query code would look something like this:
wixData.query('Members') .eq('email', email) .eq('password', password) .find() .then((results) => { // If no records are found then the result totalCount will be zero // Otherwise there is a record and it is returned in the items array if (results.totalCount === 0) { // Set error condition throw Error("No record with the email and password given were found"); } else { // Success - get the first record in the array // You need to decide if having multiple records with the // same email and password makes sense (probably not!) let foundRecord = results.items[0]; // Do something with foundRecord... } });
The result returned by find is a queryResult which contains a variety of useful info.
Hope this helps
Steve
Hey Doron,
thanks for your hint! :) I corrected that and i also saw that i used the submit-function on my login button too. So one of these things caused the problem. I chose Data-binding for my further workings.
While we´re at it: I desperately looked for an example code that queries trough my database and checks if it contains the exact email and password that were typed in into my login lightbox.
So basically i am looking for a query-function which gives out an error message, if the mail and password are not in my database. I tried to insert something on my own before but it didnt work.
Any ideas?
Hi!
It seems like this behavior is due to the fact that the elements in your Lightbox are connected to a Dataset (Data binding) while there's also code that calls them.
When you call an element with both ways at the same time the results may be unexpected.
Since you've set the Dataset to submit the data once the #loginNow is clicked and once again through the code with the ".onClick" event the data would be submitted twice
(in the occasions it succeeds to submit at all).
My advise is to choose one method and stick with it.
Note that this is relevant only to the elements that are being used both with code and Data-binding.
You can have a Dataset in a page that uses code - as long as its not on the same components.
Hope it'll work out for you.
Please let me know if it doesn't.
Doron.
https://dawdjobe5.wixsite.com/mapsngo/blank-3
Thank you! You will find my register and login function under "Academy Login" in the Menu. The code is placed in the Lightbox code section when you select "Registrieren".
Hi!
Please share a link to your site so one of us, the WixCode team, can inspect it and provide you with a solution.
Please share as well the location of the code that you use.
Doron.