Jump to content

[SOLVED] Sessions? read(), file_get_contents()?


Recommended Posts

Hi, I'm here with more questions again, please excuse my ignorance as I am a complete beginner when it comes to PHP.

 

I have a table where each row displays a filename and then a link to what should be a new page, that will open and decrypt the aforementioned file. How do I make this work? I know I need to be doing something with session variables and get data, read() or file_get_contents(). I'd be thankful if someone could give me a fairly simple explanation of how this could be done.

Link to comment
https://forums.phpfreaks.com/topic/136232-solved-sessions-read-file_get_contents/
Share on other sites

Ok, I have

 

echo "<a href="FileDisplay.php?filename=<? echo $filename; ?>">Click here</a>";

 

with which I get some kind of syntax error, I have also tried:

 

echo "<a href="FileDisplay.php<?php echo (isset($filename) ? '?filename=' . $filename : ''); ?>">";

 

with this I get another syntax error, 'unexpected $end' on this line. I'm not sure if I need to include something else. Can anyone help?

Sessions are for storing data without the need to pass through GET or POST requests so this is not really what you are after.

file_get_contents() simply reads the contents of a file.

 

If you are a beginner you should read the http://php.net functions manual to see what functions do, what parameteres they expect and what they return.

 

Your syntax is bad:

echo "<a href="FileDisplay.php?filename=<? echo $filename; ?>">Click here</a>";

 

Use

echo "<a href=\"FileDisplay.php?filename=".$filename."\">Click here</a>";

 

 

You need a PHP beginners book mate.

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.