Storing Javascript object in Wordpress User Database - javascript

I am working on a page where user can create his own unique , personalized week schedule.
Right know all about the schedule is stored in javascript object - scheduleArray.
Here is the site with my work so far
How can I store this javascript object to logged user database in WP?
I need to load it from database on site init, and later when user clicks "SUBMIT" button store it back to database.
Could you provide me any ideas, tutorials from which I can start on ?
Thanks!

As one way - add field (maybe something like next https://tommcfarlin.com/add-custom-user-meta-during-registration/) to user profile and store JSON here.
When yser submit form - you can create hidden field with this (by "onsubmit" event) and write to user field by server-side script.

Related

How to store data typed by user into input using Django

I'm kinda new to Django and I got stucked.
I want to get user input, and after that, I want to display a value that depends on it.
For example in Django I have if statement which checks input from the user, for the example car model.
So, when the user type is Ibiza I want to display "Seat", user type E92 I want to display "BMW" etc
I want to display car brands in the list that can be cleared or disappear after the user close the tab and re-open.
Which solution is the best? Database in Django? Cookies? Local storage in javascript?
Use the Database. That way you have more control of the data.

How can I make an HTML/NodeJS form go to another form based on a response, sort of like Google Form's "Go to section based on answer?"

So I have a NodeJS site and on the home page is a form containing some radio buttons. When the user clicks "Submit," I would like for the user to be redirected to another page based on the answer. This I have figured out (The buttons have an onclick attribute that changes the action attribute of the form element). However, I need to keep the data from the original form, so that after the user has "chosen their path," I know what path the took and the answers they made along it. Thank you in advance!
You could persist the client's state in a session. If you're using express, one alternative could be express-session. The way it works is that it assigns a unique identifier to the user in the form of a cookie and saves the data somewhere (memory, database, a file, etc. depending on which you choose). Then when the client makes another request, the server gets that data back with the identifier from the cookie.

Recognize form text input email address and send an email without server processing

I am currently studying web development at college and part of my course is to create a website for a mobile company that sells phones and they sell them online.
I'm trying to create a login and signup form but currently struggling to get my form to identify and use the email that the user inputs to send an email to them verifying that they have submitted is it possible and if so any help would be appreciated.
What I will suggest is in your server backend, whether it be PHP, NodeJS, etc
that you register the user in your database and have a boolean value named
'validated' true|false
set default to false, also generate a unique hash and assign it to that user under something like
'validate_hash':gnOOBhgenl2g432noug24g42
Use whatever function your backend server provides (or a library) to generate a unique has, and save this to the newly registered user
Then use a mail function to email the user with a link that will 'verify' them, by adding the unique has to a post url like this:
example.com/register/verify?hash=gnOOBhgenl2g432noug24g42&email=example#mail.com
Obviously you will have to create a script at that location and handles the link and checks the hash value given against the mail provided in the database
If the hash value matches, you can update the users status to
'verified'true
And they can now access services normally.
Majority of this wont need fancy outside libs or complicated coding, just follow what I suggested and google the things I mentioned if you need to figure out a particular element, or comment/msg me!

Remeber file selection

I have a form which asks to select a file for upload. PArt of the form requires the user to click through to another page. This is fine as I can store field values in local storage. The problem is the file selection - is there a way to remember what the user selected once they navigate back to the form?
If not can anyone suggest how to implement what I am trying to do?
Thanks
So as you are not posting some code examples, I assume that your are not interested in code suggestions.
You could use a session to store some data the user gave you over a form. CakePHP comes with the nice session helper, which makes it easy to deal with.
How to use sessions with CakePHP you can find here:
http://book.cakephp.org/3.0/en/development/sessions.html
So everytime the user fills out the form you could store the relevant data inside the session. Inside your view you just check if there is a value for that data in your session. If yes render the session value as default if not you can render the default value.

Trying to save Multi-Value Form on server for users to call up during another session

been searching here for a while on how to save form information to be re-called later.
Here is my site: http://d3barb.com
The purpose is people fill out the 100+ fields in the form and it will generate numbers corresponding to the game Diablo 3. The formulas all work perfectly, and sometimes the cookie will save the information, but I'm trying to figure out a way to save the entire "page", so users can call them up during a different session.
I've tried for about 6 hours to get setCookie / getCookie functiond to create a cookie with all the values saved, but can't seem to get it to work. Even if it was working, it would only allow the user to load their last seission when re-visiting the site.
How I would like it perform:
1.) User inputs information for the form to calculate.
2.) User fills out a "name" text field and hits a "Save" button (I have these on my test page, but don't want it live until its working), which will save the values on my server containing all the form information as they've entered it.
3.) The next time that User visits the page, they would hit "Load" to call up a previous session.
I'd like to avoid user-account log-ins, so if possible I'd like the server to save the sessions by IP address & user submitted session name, something like: 142.105.103.125.fire crusader
Currently, the page is html with js calculating everything. I can convert it php for server interaction, but if there is another way, I'm all ears.
I'm not looking for handouts, so any links to tutorials would be greatly appreciated. If someone has done something similar to this and wouldn't mind sharing that page or code with me, I can do my best to frankenstein it for my page. (pretty much how I do all my websites haha!)
Have you tried/considered HTML 5 local storage?
http://www.sitepoint.com/html5-web-storage/
should get you started :)

Categories

Resources