html news page fed from a text file? [message #387326] |
Thu, 21 May 2009 09:31 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/3415.gif) |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
Is there any way to display text on a website, but have the website read the text from a text file?
The site is written in HTML, but can contain script tags.
It's just for a stupid work project that I need to set-up, then leave in the hands of someone else.
If anyone could enlighten me, that would be cool. Running on IIS.
I'm really not a web guy at all, so if you do feel like helping, please paste the code here too.
I am hoping it'll be something simple, nothing fancy really needed.
|
|
|
|
Re: html news page fed from a text file? [message #387368 is a reply to message #387326] |
Thu, 21 May 2009 13:53 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/3415.gif) |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
Forgive me, I am able to write simple HTML pages, I have never used PHP. I am unsure that the server supports PHP, but if it does, how do I insert PHP code into an HTML page?
|
|
|
Re: html news page fed from a text file? [message #387371 is a reply to message #387368] |
Thu, 21 May 2009 14:39 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/21327.jpg) |
futura83
Messages: 1285 Registered: July 2006 Location: England
Karma: 0
|
General (1 Star) Viva la Resistance! |
|
|
reborn wrote on Thu, 21 May 2009 21:53 | Forgive me, I am able to write simple HTML pages, I have never used PHP. I am unsure that the server supports PHP, but if it does, how do I insert PHP code into an HTML page?
|
Put the PHP code after:
and before
To use HTML within PHP use the code:
echo "<HTML CODE GOES HERE>";
Although, you won't be able to use any " in the html code, but you can use ' instead to open and close the echo bit.
Edit:
Use this code to see if your server works with PHP:
<?php
echo "Hello world!";
?>
edit2:
<?php
function file_input($filename)
{
$fo = fopen($filename, 'r');
$read = fread($fo, filesize($filename));
fclose($fo);
echo $read;
}
?>
That should put the contents of the file into the page, exactly as the file is written.
Put that ANYWHERE in your page and then do:
<?php file_input('test.txt'); ?>
Replacing test.txt with the right filename.
That way you can call it multiple times in one page with different files without having to copy and past the same text.
even if you don't, you can put the main bit out of the way and call only the funtion where you want it, to make your code look tidier.
Yes, i just manipulated the info from what goztow posted but i wanted to feel useful.
This is a signature. Reading this is wasting your time.
[Updated on: Thu, 21 May 2009 15:22] Report message to a moderator
|
|
|
|
|
Re: html news page fed from a text file? [message #387420 is a reply to message #387326] |
Fri, 22 May 2009 00:22 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/3415.gif) |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
The following shows no changes on the page at all, is it right? Or does the server not support PHP? I am an admin on the server at work, so I can install it if needed...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>news page feed</title>
</head>
<body>
<center>
<b>
<big>
Some place holder text
</big>
<br />
<br />
</b>
</center>
<center>
<TABLE BORDER="0" cellpadding="0" CELLSPACING="0">
<TR>
<TD WIDTH="1007" HEIGHT="624" BACKGROUND="images\background.jpg" VALIGN="top">
<br />
<big>
News Announcement!<br />
</big>
<br />
<?php
function file_input($newsfeed.txt)
{
$fo = fopen($newsfeed.txt, 'r');
$read = fread($fo, filesize($newsfeed.txt));
fclose($fo);
echo $read;
}
?>
<?php file_input('newsfeed.txt'); ?>
<br />
<big>
<A href="newsletters.htm">Access the monthly message</A><br />
<br />
<A href="ProductInfo.htm">Access the product info page</A><br />
<br />
</big>
</TD>
</TD>
</TR>
</TABLE>
</center>
<IMG SRC="images\logo.png" ALT="logo image" ALIGN=RIGHT>
<br />
<br />
<center>
<small>
If there are any problems regarding this site, broken links, typo's or you wish to add content etc etc, please <A href="mailto:myanus@butthole.com">email me</A>.
</small>
</center>
</body>
</html>
|
|
|
Re: html news page fed from a text file? [message #387421 is a reply to message #387326] |
Fri, 22 May 2009 00:54 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/3415.gif) |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
Something is weird with my thread, I have to log out to see Goztows replies o.0
Also, did you mean insert_name_here rather then roshambo? I cannot see a post from Roshambo and was wondering if he did post but I cannot see it for some reason :-/
I havn't got a clue about php, although looking at the code posted it seems to be object orientated. I've always been lucky with website stuff, MP-Gaming is administered by Oxi, I have extremely little to do with any thing related to the site itself.
It's actually embarrassing how little I know about it really.
|
|
|
Re: html news page fed from a text file? [message #387427 is a reply to message #387326] |
Fri, 22 May 2009 01:57 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/4882.jpg) |
Goztow
Messages: 9745 Registered: March 2005 Location: Belgium
Karma: 14
|
General (5 Stars) Goztoe |
|
|
Oops, I took insert_name for roshambo, as I was posting from my mobile.
Ermmm did u try the "hello world" code insert_name posted, to check if php is enabled?
You can find me in The KOSs2 (TK2) discord while I'm playing. Feel free to come and say hi! TK2 discord
|
|
|
Re: html news page fed from a text file? [message #387432 is a reply to message #387326] |
Fri, 22 May 2009 02:49 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
![](http://renegadeforums.com/images/custom_avatars/3415.gif) |
reborn
Messages: 3231 Registered: September 2004 Location: uk - london
Karma: 0
|
General (3 Stars) |
|
|
Yeah I tried that, but nothing really happened. I ran the installer for PHP off there site. I probably need to configure something, but I've never had to do it before. Is there soemthign I am missing about installing PHP then configuring IIS to allow PHP code to run or something?
I hate this, at least with C I have half a clue what I'm doing, I really don't like this at all.
I really really do appreciate the help.
[Updated on: Fri, 22 May 2009 02:49] Report message to a moderator
|
|
|
|
|