vendredi 24 avril 2015

Storing checkbox value on server side

For my home automation project (using a Raspberry Pi with an Apache server and a configuration webpage) I'm trying to save a checkbox's setting to a file on the server side, but I can't get it working in my situation. Using php with fopen() and fwrite() I can store any string into a text file, that's no problem. The issue is that the form uses POST and I can't seem to figure out how to write my code in such a way that:

1) the checkbox itself is set to the value that is currently present in the text file ('remembering and retrieving' the setting);

2) the setting that was just set by the user is written to the file, which happens when the page loads (POST).

These actions seem to get in eachother's way because php is server side. I've also looked into localStorage (javascript) but I can't seem to figure that one out too. It doesn't really matter which method or language I use to save the checkbox's setting on the server side.

Which method could do the trick?




Aucun commentaire:

Enregistrer un commentaire