Page 1 of 1

Display text file data to textarea using php

Posted: Wed Jun 11, 2008 6:03 am
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

Re: Display text file data to textarea using php

Posted: Wed Jun 11, 2008 7:12 am
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>";
}
?>

Re: Display text file data to textarea using php

Posted: Wed Jun 11, 2008 9:43 am
by superdezign
To display text as is, you could make use of the <pre> HTML tag instead of a textarea, as well.

Re: Display text file data to textarea using php

Posted: Thu Jun 12, 2008 6:16 am
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