I created Database with using the details from the signup Form. Now how can I retrieve that data through correct password with it’s corresponding Enrollment Number?
Please add more details, screenshots, code to your question so it will be easier to see where you are in your project.
This is my database.
Now I want to retrieve that data by giving the enrollment and password. The data should display on another page in the form of table as I click on Login Button. (This data should be display in a table if the enrollment and password will be match with the content of the database)
Hi Tejas,
In the current configuration, you can switch the student attendance page to dynamic, in order to display the relevant item when a user is navigated to the page.
Then you could write a code similar to the example below to check the user and pass against the collection and navigate the user to the enrollment (“Student Attendance”) page if the information is correct.
let pass = $w('#pass').value;
let user = $w('#user').value;
wixData.query("myCollection")
.eq("user", user)
.eq("password", pass)
.find().then(res => {
if (res.items > 0) {
//user and pass match, navigate user to enrollment page
wixLocation.to("/enrollmentPage?" + res.items[0].enrollment)
}
else {
//wrong user and pass, display error.
}
})
.catch(err => {
console.log("Unable to access collection: " + err)
})
However there are couple of issues with this approach.
The first - sensitive login information is combined with other information. This means that every time you’ll need to access the enrollment info, you will also be accessing the login information.
A more secure approach will be to split the collection into “member profiles” collection, which only stores the user, password and the user id (you can use the built-in _id field) and another collection with the relevant information, with a reference to the _id field.
The second - the login information is stored and transmitted in plain text, which is less than optimal.
The solution here is to use password hashing. The server sends a random string to the client > the client then adds the random string to the password, hashes it and only then it is transmitted to the server, which then decrypts the hash. You can find more info about login hashing online.