Display text file data to textarea using php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nehahsri
Forum Newbie
Posts: 2
Joined: Wed Jun 11, 2008 5:54 am

Display text file data to textarea using php

Post by nehahsri »

hey
I am trying to display my data which is present in a textfile (data.txt) format. I have to display this file as it is (the format of the file should not change) in a new window when a user asks for it.

to be more precise- I have a data.txt file which contain information about computers....these are in perticular format which i dont want to change.
Now when a user from the front end ask for this data it should disply it in a new window (IE) or may in a textarea (inside a form) in a new window (IE)...

please if any one can help me with this

Neha
hansford
Forum Commoner
Posts: 91
Joined: Mon May 26, 2008 12:38 am

Re: Display text file data to textarea using php

Post by hansford »

first check if they asked for the data file by checking some $_POST variable. Then we let javascript open the file in a new window

<?php
if(isset($_POST['getdata'])){

echo "<script language='javascript'>";
echo "var win = window.open('data.txt','data');";
echo "</script>";
}
?>
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Display text file data to textarea using php

Post by superdezign »

To display text as is, you could make use of the <pre> HTML tag instead of a textarea, as well.
nehahsri
Forum Newbie
Posts: 2
Joined: Wed Jun 11, 2008 5:54 am

Re: Display text file data to textarea using php

Post by nehahsri »

superdezign wrote:To display text as is, you could make use of the <pre> HTML tag instead of a textarea, as well.
hey thanks this html tag worked perfectly..
thakns
regards
neha
Post Reply