Jump to content

[SOLVED] Display text file in a new page depending on which link has been clicked


Recommended Posts

Hi guys,

 

I'm missing a bit of info to get this done really.

 

When someone clicks on the "View Log" link, a second PHP page/ browser window should open display the contents of the log file (which is a simple text file). I have two log files and they should be displayed (if possible) by the same PHP page. Perhaps I'm a bit slow ATM but any hints are greatly appreciated.

 

 

<td<a href="">View Log </a></td>

In the simplest fashion

<td><a href="view-file.php?file=1.txt">View Log</a></td>
<td><a href="view-file.php?file=2.txt">View Log</a></td>
<?php
// view-file.php
$fileContents = file_get_contents($_GET['file']);
print $fileContents;
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.