Backend advice needed for noob to backend

Ok, so I’m learning front end. Know HTML, CSS, javascript, and jquery (up to fetching data from an API with Ajax). I came up with a website (tool) idea that would help my company at work. What it requires is to load data when the page loads and write data when the page closes. Now, if it was only on 1 pc I know how to do this using local storage and unload events in js. However since the company I work for has 2 locations, I will have to do this server side. Basically when page loads, if there is data it will create ULs from it (basically, a little more complex than that). I’ll also be able to add data to the ULs using a text input and some event listeners (know how to do this with javascript if it wasn’t server side) and then when the page closes the data in the ULs is saved on a file on the server. Can I do this with PHP? (still need to learn php)

You could build a backend with NodeJS and Express. Then you could use JavaScript.

2 Likes

If you are still trying to learn how to connect frontends and backends (like understanding the full picture) Firebase (Google’s backend as a service) will let you focus more on integration and less on setup, it’s a great learning tool but expensive for growing websites so learning stuff like Express.js and Mongo is still important.

1 Like

Yup, you could do this with PHP or any other backend language.

One way would be to have PHP read from your DB and respond with templated HTML in response to the initial GET request.

But PHP has no way of knowing when the page is closed, so you could use a Javascript unload event to trigger an AJAX POST request (using jQuery or otherwise) to tell PHP when and what to save to your DB.

I think the best thing would be to use nodejs + express as your backend and then you can use Vue.js and the created() or mounted() lifecycle hooks to fetch data when the app starts. Great thing is they are all just javascript in the end

1 Like

Thanks everyone for the replies! I may first try it with Jquery and Php as I have been learning PHP a little. I still need to learn Node but if I struggle with PhP I’ll switch to node.