Question

I've got a raspberry pi with raspbian and all I've done is installed apache2 and created a small web site i want to create a database. is this possible without using mysql or other database software. i want to use .JS or a text based database I want to be able to save the contact details in a text format. can someone point me in the right direction a simple example would be appreciated all online research wants mysql etc all i want is a simple example as in enter name and submit i want that name to be logged so if name entered again it will say welcome back once i know this mechanism i can add all the other fields. The reason i want this format is so i can see the list that I'm creating. i just can't get to grips with mysql I've spent months trying to understand mysql but its just not going in so want to simplify the database to minimal workings so i can complete my site. I know .Js isn't so secure but its a demo so security not important at this point any help appreciated

Was it helpful?

Solution

It would be possible to use JSON for your data storage. It will be a key-value storage. On each page view you will have to load the entire file into memory and parse it. From then on it is possible to loop it to search data or get data from a key. This requires no extra software just PHP with Apache.

How to: Build an array, use json_encode to create the JSON and save it using file_put_contents(). Remebmer to save the whole array and not just the newly added element.

This is not a relative database but might do the trick if you build an intelligent system with cookie's to store an ID that is associated with a user.

Alternative you could use serialize() instead of json;

OTHER TIPS

If you don't mind to use different way of storing data you can use either Google App Engine or mongolab or other cloud based databases

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top