1

How do I save html registration form data into a JSON file then log in based on it, without using any server side scripting languages? I want to use only Javascript and jQuery.

HTML file "simple form" contains:

First Name, Middle Name, Last Name, User Name, Password, Confirm Password, E-Mail, Phone

When a user enters his data and clicks the register button, his data will be saved in a JSON file on the server. I have created this JSON file on the server as:

C:\inetpub\wwwroot\usersData.txt

And based on this file usersData.txt, when another user wants to register, I need to check the that user name is unique, if it is a unique user name, save his data back to the JSON file.

I also need to know how to update the password in the JSON file when I use a hypothetical change_password() JS function.

3 Answers 3

2

Under normal circumstances, you should not be able to modify files on the server from client side scripting. Allowing that would let a malicious user put anything into that file, or, depending on configuration, any other file the server can access.

Doing only authentication client side is also problematic. If the client can download the userData.txt, the malicious user would know every user's email, password and phone number; using the email and password he could probably login to the user's email account, and another bad stuff can happen, so please don't do it!

So, there's no way to properly do it clientside...

Sign up to request clarification or add additional context in comments.

4 Comments

Totally agree wz u sir, thanks for your reply, but i want simply export my html form data as i explained above into json file *.txt
You can't write arbitrary files from Javascript neither client nor server side. The closest you can get probably is to write a simple script that runs server side, and saves everything you POST into a file; but that is still a bad idea from security perspective. Why do you want to do all this stuff client side?
just for training purposes, if i can do this, plz help me
In that case, you should rather write it server side, just for training purposes. There is no sense doing it client side.
1

I think you would be better served by not bothering to collect the data -- client-side authentication can never be trusted. Don't try to build a system that pretends to be safe. Instead, make the insecurity very obvious: store the username in a cookie and let any user type any username into whatever field sets the username cookie. (The cookie is just so they don't have to re-type it all the time.)

If you don't care about security be upfront and honest about it.

Comments

0

If you plan to do authentication on the server side, which you really really really should, you have to have something listening on the server, either your code or delegate the authentication to some other system. There's no way to magically update a file on the server from javascript running in the browser.

1 Comment

totally understand you, thanks for your reply, but i want simply export my html form data as i explained above into json file *.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.