I have a form in file.php , when i submit that form it redirected to another page.There i display all the values that i got in the form.Now there is a button called Ms word when i click that the current page has to exported to a word file and download. It is downloading but the values are not displayed. i could display only HTML WHY?????

Because that's all the page will ever be is html. You can't view php from a regular website, unless you're using phps, as all the php is processed server side. In short, the client (your browser) never sees the php so it can't print or display something that it can't see.

You have to use header as mentioned here

<?php
header('Content-Type: application/msword'); // this line you can change based on your file type
header("Content-Disposition: attachment; filename=\"helo.doc\"");
readfile($new_file);
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.