zunebuggy Posted September 7, 2013 Share Posted September 7, 2013 I created a website for my Mother's civic association. She is in charge of the associations announcements. She does not know HMTL. I am new to PHP. I want to create her Announcement/Event page using PHP and want her to be able to simply write the events in notepad and I will give her instructions on how to upload that txt file to the website. From there I want my PHP page to read the txt file and display the contents on the page. If someone can just help me get the part that can open and reading each line of a txt file from a web location, I think I can handle outputting the results to the Announcement page. I am an old vb programmer and I need something that is the equivalent of this below, but in PHP and from a web location and not a drive: Open myFileLocation & "/" & myFileName For Input As #1 Do While Not EOF(1) Line Input #1, myLine ' do stuff here Loop Close #1 Thank you. Quote Link to comment Share on other sites More sharing options...
Psycho Posted September 7, 2013 Share Posted September 7, 2013 Assuming you don't want to deal with the trouble of learning to use a database there are better solutions. The simplest one is to store the text for the announcements in a simple text file on the web server. When someone goes to the announcements page it will read the text from that file to display it. Then, when your mom wants to edit that page, give her a page which loads the text file into a form and allows here to edit it and submit. When submitted it will update the text file. No need for her to write in notepad, save it, and then upload it. And, you can easily expand that solution to use a "rick text" type editor such as this forum uses for writing your posts that allows you to add properties such as bold, italic, underline etc. There are plenty of free options available and you can easily implement them to store the content in a text file as above. Quote Link to comment Share on other sites More sharing options...
zunebuggy Posted September 7, 2013 Author Share Posted September 7, 2013 Yes I just don't know how to have my PHP read the text. Thank you. Quote Link to comment Share on other sites More sharing options...
kicken Posted September 7, 2013 Share Posted September 7, 2013 file_get_contents file_put_contents Quote Link to comment Share on other sites More sharing options...
jcbones Posted September 7, 2013 Share Posted September 7, 2013 To read it without any styling. <?php $file = 'mytext.txt'; $contents = file_get_contents($file); $contents_formatted = nl2br($contents); echo $contents_formatted; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.