Custom Signing Up to Custom Database

Good evening all,

Hopefully someone will be able to assist with that.
I have created a Custom Sign Up form and just trying to transfer all the filled in information into my Custom Dataset (Tennis Players). There should be something wrong/missing in my code, as none of that filled in information transfers to my custom database.

The code is following:
import wixData from ‘wix-data’ ;
import wixLocation from ‘wix-location’ ;

$w.onReady( function () {
$w( ‘#button2’ ).onClick( () => {
//button2 is a Sign Up button

let toInsert = {
“name” : $w( “#input1” ).value,
“email” : $w( “#input3” ).value,
“password” : $w( “#input4” ).value,
“plays” : $w( “#dropdown1” ).value,
};

//TennisPlayers is my custom dataset
wixData.insert( “TennisPlayers” , toInsert)
.then( (results) => {
let item = results;
} )
. catch ( (err) => {
let errorMsg = err;
} );

});
});

//once registered, transfers new user to his profile page (mii-profile)
export function registrationForm1_wixFormSubmit() {
wixLocation.to( “/mii-profile” );
}
export function registrationForm1_wixFormSubmitted() {
wixLocation.to( “/mii-profile” );
}

Thanks in advance!

Regards,
Danny

Hi Danny,
Can you add a consoke.log to the .then()
With the results you get.
Also, is the collection name right?
Go to the collection settings and check the value name of it.
Maybe you changed the name once but the value name doesn’t change anymore.

Kind regards,
Kristof.

Hi Kristof,

Thank you for your answer.

It was set up to a different name indeed! I have change it to the following:

and here as well:

Still not getting any results.

How to add consoke.log?

I am a complete newbie in programming, please forgive me for the stupid questions)

Regards,
Danny

Hi Da P,
No worries their are no stupid questions only stupid answers.
I will try to guide you trough it but i’m not on a computer atm.

First of all:
Or you use a dataset and send data to it with the connection or you use wixData. Not both.

So what you will do is.
Remove the dataset.(i’m more used to using code)

consooe.log() is a function to log your code.
For example if u use
console.log(results)
It will show you what you have inserted(add the console.log(results) in the .then code block. Where you added - let item = results
This way you can go to preview, click the button and below in will log the result.
If their is an error it will run the .catch code block.
Also put an console.log(err) there. This will log the error.

This way you know the button works.
If it gives an error you also know what the error is.

Second: does it work in preview?
Ifso, the problem lies with the permission from the collection.
This could be an read only collection wich doesn’t allow you to add items to it.
Be aware. An admin has more permission then a normal member so be sure to test it with a normal member account aswel.

Third:
If the there is no log shown.
Select the button element, right from the code panel you see the property menu.
Go to the onClick event handler and select it. A name will be given and press enter.
There will be some code added to the page. Add the code u used before in your previous onClick event and paste it in the now onClick event. Remove the old one.
Try it again and see what it does.

Please respond when you tested it out.
Its 23:17 here and i’m off to bed so i will check it out tomorrow

Kind regards,
Kristof.

Hi Kristof,

Sorry for the late reply, only managed to play with code after the work.

I have deleted dataset from the page and tried adding console.log, however I wasn’t sure how to test the code.

Regarding adding onClick button2 code - it didn’t help:

Second: does it work in preview? Ifso, the problem lies with the permission from the collection. This could be an read only collection wich doesn’t allow you to add items to it. Be aware. An admin has more permission then a normal member so be sure to test it with a normal member account aswel.

  • How to check that?

Thank you in advance.

Regards,
Danny

I think I have answered my last question: permission is okay

I have also changed it on the code to TennisPlayers, instead of tennisplayers.

Still nothing has changed.

Regards,
Danny

Oke first of all,
The toInsert should be in the onclick function.
Aswel as the wixdata.toinsert.
What you do now is.
Page is loaded. Textfields are set to toInsert but the textfields don’t have any value yet.
When you add all this in your onClick (wich is below on your code page) it probably wil work.

I probably will find time tomorrow(in around12hours) to answer properly, today i have been in the hospital the whole day

If you do the above like i said and it still doesn’t work let me know and post the code again.

This way i het notified and wont forget to reply :slight_smile:

Kind regards,
Kristof

No worries Kristof, sort your things out first, my code isn’t so urgent)

Right, I think I have found the first error:

Regards,
Danny

When using a checkbox you should use .checked instead of .value

Try using this site to check the elements propertys and what they do.

Wix.com/velo/reference

Search for checkbox.
It will show what .checked does with an example

Hi Kristof,

Thank you for this link.

I am a bit confused what exactly to add.

and this what I have add, which seems isn’t right (however error on the code has disappeared)

How to open hncow.js in order to debug this code?
Loading the code for the Custom Signup page. To debug this code, open hncow.js in Developer Tools

Regards,
Danny

What you added you didn’t need.

The first image shows you how to get the value(true or false) of an checkbox.

The second image lets you set the checkbox.
If you set it to true the checkbox is filled
If you set it to false.
The checkbox is empty

The 3rd(the one u used)
Is to togke between true or false
By adding the ! Before it you change the value
True becomes false or false becomew true

In your previous post you marked your checkbox value that it have an error.
Just cha ge the .value to .checked. that should work.

Thanks Kristof. This is the first thing I did. I was getting an error:

The checkboxgroup is it an multi selection ? More then 1 option possible?

Yes

Oke then you have to search those reference instead of from a checkbox.
Also make sure you have it as an array in your collection

Sorry Kristof, was a little bit busy this weekend.
Not really sure how do I need to change multi selection in order to sort the issue out:

Got an answer from WixSupport team: was a conflict with permissions:)
I have just changed the permission, so anyone can create a content for this collection and now I am able to see the registered players in my database! Brilliant!

The issue I have now, is that information from the dataset doesn’t transfer into +My Profile page.

Will someone be able to assist with the code? It says “wixUsers is not defined”.
I am trying to set up user’s ID prior to full registration in order for the registered member to have a chance to update the information on his player’s profile page (issue above).

Sorted. Now the issue with the brackets

If you would show your code in a CODE-BLOCK & NOT in PIC , perhaps then i would help you.
If i am honest, i am to LAZY to retype all your code :grin:

Hello --> i am a CODE-BLOCK 😜