Hello All,
I have some Raspberry Pi’s that I have wired up to some 40x2 character LCDs. The LCDs display messages held in a text file. If I want to change the message I have to ssh in to the Pi and edit the text file. I thought it would be cool to do this from a web interface, and found something that looks perfect (not my code) but it does not seem to work, however it is from 2004 and I am guessing syntax and such has possibly changed.
The code I am using should write to and read from a file called my_data.txt, but doesn’t seem to do anything, I don’t get any errors from the browser either.
Platform:
Raspberry Pi 3
Raspbian Jesse
PHP5
Apache 2
I have tried to make the www-data the file/folder owner, and used chmod 777 to ensure that their are no rights issues.
I know it’s something I have done/not done, but any help would be greatly appreciated.
Code:
[php]!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
Click on "Get" to display the current text file contents. Enter text and click on "Submit" to update the text file. Type ‹br›<$ | |
<?php if (isset($gettext)){ $myfile = fopen("my_data.txt","r"); $mydata = fread($myfile,filesize("my_data.txt")); print $mydata; } else if (isset($submit)){ $myfile = fopen("my_data.txt","w+"); $entry = ereg_replace("\n"," ",$entry); $entry = stripslashes($entry); $mydata = "&mytext= $text_file &\n\n"; fwrite($myfile,$mydata); fclose($myfile); $myfile = fopen("my_data.txt","r"); $mydata = fread($myfile,filesize("my_data.txt")); print $mydata; } ?> |
[/php]