...

View Full Version : overwrite same file with javascript



TheElect2049
03-26-2012, 04:21 AM
I want to make an rpg with a username and password login without a database,
I was thinking, maybe i could make it when the user presses "sign up" the webpage creates a new file in the same directory that stores all their information. I researched it and realised it wasn't cross browser compatible. Therefore I came up with an idea to store all the users' information in a array.

What i want to do is that when the user presses "sign up" it adds that user to the array and the html file overwrites itself so the new user is saved into the array :D:D:D

Any ideas?

devnull69
03-26-2012, 08:35 AM
Array? Where do you want to hold that array? Arrays are stored in memory of the one machine running the current script/program. Did you think about persistent storage of that array?

TheElect2049
03-26-2012, 08:39 AM
The array will hold the usernames and passwords in a seperate .js file

Philip M
03-26-2012, 08:45 AM
JavaScript running in a browser is a client-side language. JavaScript does not have any commands for reading or writing files. Modern browsers can read files on the server using an Ajax call, but otherwise JavaScript has no capability to read from, write to, modify or delete a file (except a cookie), communicate with the server, access a database, the client's operating system or the Windows registry, or alter the default behaviour of the browser.

In short, what you are trying to do is not possible. And if it was anyone could see the usernames and passwords simply with View Source.


Quizmaster: In US history, the body known informally as the Warren Commission appointed in 1963, investigated the assassination of which President?
Contestant: George Washington

Mishu
03-26-2012, 12:33 PM
I want to make an rpg with a username and password login without a database,

Any ideas?

The only way I can think of to do that is with a server side script, called with or without AJAX, to access and edit a file the server. Ther server file could be a php file containing an array of usernames or just a plain text file.

The only pure javascript way I can think of is to use MS specific code and features for IE which allow you to access the user's file system, but users will have to change their security settings to alllow you to this. So it's not practical for that reason plus it will only work in Internet Explorer.

TheElect2049
03-27-2012, 08:48 AM
:\ ohk thanks for the wise information i'll just use offline storage lol

Old Pedant
03-27-2012, 08:53 AM
:\ ohk thanks for the wise information i'll just use offline storage lol

Hmmm....like paper tape? I have an old teletype machine you could use.

Then any time you need to bring the storage online, you just have to walk over to the machine and collect the punched tape and feed it back in to the reader. Works great. At 10 characters per second, no less.

Very modern technology. Heck, it was the ONLY thing to use in 1975 or so.

**********

Okay, I give up. What in the heck *DID* you mean by "offline" storage?

Mishu
03-27-2012, 09:47 AM
Hmmm....like paper tape? I have an old teletype machine you could use.

Then any time you need to bring the storage online, you just have to walk over to the machine and collect the punched tape and feed it back in to the reader. Works great. At 10 characters per second, no less.

Very modern technology. Heck, it was the ONLY thing to use in 1975 or so.

**********

Okay, I give up. What in the heck *DID* you mean by "offline" storage?

Are you still in the last century?:)


Okay, I give up. What in the heck *DID* you mean by "offline" storage?

let google be guide you into the 21st century :) offline storage (http://www.html5rocks.com/en/tutorials/offline/whats-offline/)

TheElect2049
03-27-2012, 12:37 PM
=.= html5 offline storage? Haven't u guys heard about it?

Mishu
03-27-2012, 12:50 PM
=.= html5 offline storage? Haven't u guys heard about it?

I have :) and I posted a link for the old pedant.

Philip M
03-27-2012, 08:31 PM
=.= html5 offline storage? Haven't u guys heard about it?

The difficulty is that not all browsers include all of the new APIs, and you may have to support older browsers that don't include any of them at all. In a few years things may well be different.

rnd me
03-27-2012, 09:17 PM
=.= html5 offline storage? Haven't u guys heard about it?

year ago, but that won't anyone store user names and logins. well, one could store one's own credential, but the point was to let more than one user login. i guess if you only play the rpg on one computer it would work. that sounds exciting...

since localStorage is seen by only one computer, the size of your application pool is quite limited by localStorage. If you added w3p2p, i guess you could server from localStorage, but i don't see any mention of that in the thread...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum