FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

is it possible to get a html text box to load a .txt file?

 


andy26
hi i need this text box www.crazybunny.info to load from a .txt file is it possible to do so if so how do i do. please could someone help with maybe a bit of source code or something. i would like it so a .txt file in the public_html directory to be loaded and have the contents loaded into my news text box on my homepage, as this would be a much easier way for me to upload new news into the news box without having to edit the page then upload it.
eznet
I don't know if this is what you are looking for or not, but you can load the contents of a file (that resides on the server, or other networked area) into a variable in PHP and then print the contents of this variable (ie the file) to the screen.

Code:

<?php
$string = fopen("textfile.txt","r");
echo $string;
?>


The code is pretty self explanatory: The first line (<?php) starts the php script, the second line declares a variable ($string) and sets the contents of the specified open file opened with fopen (opens the file specified in the parentheses - in this case as read only.). The 'echo $string' line is printing the contents of the $string variable (the text file contents that are store within it) to the screen.
This is pretty universal and can be used and formatted however you see fit. Luckily, Firhost has PHP installed, so there is really nothing else you need to do other than include this script in your file and make sure that the file is named *.php (ending with 'php'). The php file can contain a mix of HTML and PHP. Also, html markup can be included in the text file you are importing and will be rendered as html once echoed within the webpage.

-Matt
Related topics

Help needed to make text box and poll script
VB 6.0 saving multipul .txt from a text box need help
VB 6.0 need help loading a .txt file into a text box
Dreamweaver < Serif webplus
script backup database

OK, really easy html script...
I need a complex php/flash form... 250FRIH$
Can a php page generate a file?
Box Message
html form help needed

(official) Firefox & Thunderbird 1.5 Beta2 Now Available
iSpeak Dashboard Widget
Football Manager 2005 (PC) Review feat screeshots
Scroll tag
Need a web template, I'll spend up to...
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.