Forum Moderators: coopster

Message Too Old, No Replies

can I use php to read from/write to other files on server

new to php

         

icpooreman

4:02 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



I've got a news section on my page and I want people in the company to be able to fill out an online form to add new news stories so that the website looks constantly updated. all the news stories and scrolling abilities are currently in a javascript file which are written out to the page when a user loads the page.

So preferably I'm looking to take in information from a form and write that information into my javascript file if that's possible.

Or if I can't do the above I want to take in information from my form and write to a database or new file then read that from my javascript file with php.

Zipper

4:45 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



You can accomplish your task using both methods. However the first method is a very delicate solution as your javascript files will have to have write permissions in order to be updated thru the php script. that would result in the files being able to be edited freely by anyone, thereby making it a major security issue.

If you want to use plain texfiles, you will still need to have files with write permission which could still be traced from the client-side. Also, reading them through javascript will require something like ActiveX which is not found in every single platform/browser and therefore might lead to compatiblity issues.

Your best option is to use a database which would be ideal if you have the neccessary resources. You could organize your users and their entries and even use it to create your text files or dynamic news feeds using XML.

icpooreman

5:59 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



Ya a database would probably be the best way to go.

This may be a dumb question but can I make file permissions different for different users/local cpu. For example could I make my javascript file only writable on the local machine so only the server could write to it?

Zipper

4:02 am on Aug 6, 2005 (gmt 0)

10+ Year Member



Yes you could set different permissions to different users within the system. However all your site visitors belong to one group and if you need them to be able to write to a file then you have to set that permission to the entire group so that when they call the php script or whatever they will have enough previledges to be able to update/save the file(s).