Hi amoid! Thanks a lot for all your explanations and the json example. Yes, the decodeBase64() could frigthen a “little bit” beginners You’re right: if ones wants to make a real example of a registering and login page ones should use a service side script (JS, PHP) and a database on server side too. But that’s not my intention here because it could take for a very long time before a beginner learns all the necessary skills to be able to write such a project or even simply understand its code (client / server paradigm, database modeling, SQL, web application, …)
My idea is to make make simple code in order to simulate this registering and login process on client side only with p5.js and html. In this simulation, a simple array, list or json table saved into a file could simulate a database table.
The process would be the following:
- the user register with an html form
- the application gets the user data from the form fields
- the user data are added to a list or json table
- the list or table is saved into a file on client side
- the user goes to the login page and enter username and password into login form
- the application reads the file and import back the user data
- the application compares user password to validate or not the login
But of course, during the same session, we can pass over step #4 and #6. And as an alternative we can give the opportunity to user to download the table as a file in order to save it to the sketch folder (assets) if he doesn’t want to loose the data he entered. This would replace step #4 that would be done mannualy. And afterwards the step #6 could be possible for the login.
If saveStrings, saveJson, … functions could also works as symetric functions for loadStrings, loadJson, … it would great too. Because for beginners (and non beginners: I’ve been programming for more than 36 years…) the symetric names used for those functions are confusing concerning what they really do and their roles, leaving to think they have similar contracts.
The problem is that the mainstream idea today is still to impose one common language to all teachers. And most of people will vote for Python. It’s a very good language but mainly a ‘desktop’ language (of course it can be used on server side but for beginners it has no really interest). If Python is choosen and imposed, we can forget to use p5.js (a very creative one that could motivate our students because they live every hour in the world of the the web) in order to teach programming to our student.
That’s one of the reason why I try to find a solution to enable a JS program to be able to do the same in an easy way and I hoped that saveStrings and loadStrings() could provide this way…