Link to home
Start Free TrialLog in
Avatar of derhamm
derhamm

asked on

Best language for displaying a text file's data in an html page

I don't have cgi access, but I am allowed a script that writes form data to a text file that I do have access to. I'm looking for a way to display the text file's data in a web page. . like a guestbook. Using the <pre> tag would be acceptable too.
Avatar of tconnolly
tconnolly

well if your hosting server allows Server Side Includes, then you could use an SSI command to bring in the text file. No real special coding required, just go about coding your page and then when you want to bring in the contents of the text file, put the following code in:


<!--#include file="textfile.txt" -->

you could even control formatting (albeit somewhat limited) by surrounding the command with <p> tags or other tags and use CSS to control the properties

the only other thing to remember is yto name your files with a .shtml extension...

hope this helps:)

TomC
Avatar of derhamm

ASKER

Sounds great. Tried it but the text isn't displayed. I'm sure it's because the 80Megs of free webspace Earthlink provides it's broadband subscribers doesn't include SSI. Haven't read that anywhere but I assume it's probably the case. Just in case, is there something I need at the head of my .shtml code? Thanks for the info.
copy and paste the code for me so i can check... also do you have any details on what earthlink provides you or if you give me your url, i can try to see what type of server your site is on and perhaps i can give you more info
Avatar of derhamm

ASKER

Here's the link:
http://home.earthlink.net/~denhamm/append.shtml

Here's the code:
<html>
<head>
<title>Sample Form</title>
</head>

<body>
<h1>Sample Form</h1>
<hr>

<form method="post" action="http://home.earthlink.net/cgi-bin/appendto">
<input type="hidden" name="appendfile" value="data/formresults.txt">
<input type="hidden" name="thankURL" value="http://home.earthlink.net/~denhamm/append.shtml">
<p><b>Name:</b><input type="text" name="name" size="30">
<br><b>Email:</b><input type="text" name="email" size="30"><p>
<b>Comments:</b>
<br><textarea name="comments" rows="10" cols="50"></textarea>
<p><input type="submit" value="Send">
<input type="reset" value="Clear">
</form><p>
<hr>

<!--#include file="data/formresults.txt" -->

</body>
</html>
Avatar of derhamm

ASKER

Here's the link:
http://home.earthlink.net/~denhamm/append.shtml

Here's the code:
<html>
<head>
<title>Sample Form</title>
</head>

<body>
<h1>Sample Form</h1>
<hr>

<form method="post" action="http://home.earthlink.net/cgi-bin/appendto">
<input type="hidden" name="appendfile" value="data/formresults.txt">
<input type="hidden" name="thankURL" value="http://home.earthlink.net/~denhamm/append.shtml">
<p><b>Name:</b><input type="text" name="name" size="30">
<br><b>Email:</b><input type="text" name="email" size="30"><p>
<b>Comments:</b>
<br><textarea name="comments" rows="10" cols="50"></textarea>
<p><input type="submit" value="Send">
<input type="reset" value="Clear">
</form><p>
<hr>

<!--#include file="data/formresults.txt" -->

</body>
</html>
Avatar of derhamm

ASKER

Here's the link:
http://home.earthlink.net/~denhamm/append.shtml

Here's the code:
<html>
<head>
<title>Sample Form</title>
</head>

<body>
<h1>Sample Form</h1>
<hr>

<form method="post" action="http://home.earthlink.net/cgi-bin/appendto">
<input type="hidden" name="appendfile" value="data/formresults.txt">
<input type="hidden" name="thankURL" value="http://home.earthlink.net/~denhamm/append.shtml">
<p><b>Name:</b><input type="text" name="name" size="30">
<br><b>Email:</b><input type="text" name="email" size="30"><p>
<b>Comments:</b>
<br><textarea name="comments" rows="10" cols="50"></textarea>
<p><input type="submit" value="Send">
<input type="reset" value="Clear">
</form><p>
<hr>

<!--#include file="data/formresults.txt" -->

</body>
</html>
ok, well it appears that earthlink is running an Apache web server on a Unix platform, so you could probably try PHP...

so rename your file with a .php extension and to insert your text, use the following code...

<?php
   include("data/formresults.txt");
   ?>
Avatar of derhamm

ASKER

Thanks for your help tconnolly. PHP doesn't seem to work either. I think Earthlink strips us free webspace users of the basic extras most webmasters get like custom cgi, php, ssi, etc... I appreciate your help and if I don't get a working workaround in a few days I'll accept your php as an answer. Could you tell me what steps you took to find the web server and platform Earthlink is running? Thanks again.
http://uptime.netcraft.com/up/graph/

find the form on the left hand side that says

"what's that site running?"
ASKER CERTIFIED SOLUTION
Avatar of Shalom Carmel
Shalom Carmel
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of derhamm

ASKER

Cool! I hadn't researched that tag yet. Anything work in Netscape? I could have some javascript determine the browser and display one or the other. If nothing works in Netscape I'll just have the script write an option to open a window containing the text file.
iframes are not supported in older versions of netscape (les than 6)
Avatar of derhamm

ASKER

Cool! I hadn't researched that tag yet. Anything work in Netscape? I could have some javascript determine the browser and display one or the other. If nothing works in Netscape I'll just have the script write an option to open a window containing the text file.
IE and Netscape 6 are more than 95% according to this site.

http://www.w3schools.com/browsers/browsers_war.asp

My experience shows even a larger share.

ShalomC
Avatar of derhamm

ASKER

I ended up using the <iframe> tag to solve my issue.

<iframe  src="myfile.txt" height="300" width="400" name="textfile" frameborder="no" scrolling="auto"></iframe>

Thanks!