|Newbie needs simple php script|
I need a small php script that updates my site from a txt file
Hi I am a complete newbie to php, but not html or programming (I know a lot of html, and a little programming in basic and perl). I am the webmaster of a small local site, and have decided to put a 'recent news' section on all the pages. Instead of typing out every change in every .html document, is there a simple php script that can link to a txt file, insert the contents into my html file and format it accordingly? The webpage in case you're interested is at <snip> Any help is greatly appreciated and I am only too happy to put a link to whoever helps on my site. If nobody knows how to or doesn't have the time, is there a site with a similar script on it I can use? I have looked all around the web and can only find scripts that let me add change and delete information, with unlimited users and admin mode, with smilies and cookies etc...!
Thanks in advance
[edited by: jatar_k at 5:42 pm (utc) on Jan. 9, 2003]
[edit reason] No urls thanks, See WebmasterWorld TOS [webmasterworld.com] [/edit]
Hello and welcome to Webmaster World,
to make things very simple, you do not need a program, but just the "include" command in PHP.
You can include whatever you like with this command. I suggest that you also put the required HTML formatting into the txt file that you want to present on different pages.
Good luck and lots of fun!
For the correct syntax go to php.net
Do the pages need to have the .php file extension, or can they be regular .html pages?
No, they could stay with the htm / html extension as long as the server is configured correctly. The server has to interpret all htm(l) files as php scripts. Your webhost can do the configuration quite easily.
But you will still have to have your html mark-up in your text file, unless you are happy with plain text. I think?
Yes, and since macmuso says he does OK with html programming, this is the most easy way to include his news or ad or whatever.
If you are just doing simple includes you could, as was recommended, use php include functionss [php.net]. If you want to make php parsed html extensions you need to make the changes to your server config.
look here for the AddHandler Directive [httpd.apache.org] for Apache
The only thing is that if you are using Apache you could just use SSI for simple includes.
How do I enable SSI [httpd.apache.org]
Thanks. I tried keeping the file extension the same but it didn't work, so I just changed the name from index.html to index.php etc and that seems to work, instead of hassling the hosting provider