Outputting a PDF File through a PHP File in Protected Area
Posted: Wed Jun 16, 2004 4:53 pm
Can anyone help me with this, I have tried everything, and I just can not get it to work.
I am trying to output a pdf file within a php file. The files are within a password protected area that uses an SQL database to store username/password/userlevel, and sets a cookie that expires upon clossing the browser. I am trying to get so that they can open the pdf files while in their individual customerarea, but I do not want them to be able to bookmark, or type the file path directly into the browser, and pull the pdf file up. I want them to have to go through the login screen like they would have to to get to any other password protected page.
This is the code I am using. It works fine until I try to add the if cookie set string. When I add this I keep getting a parse error message.
Here is the code I am trying to use:
ATTN: this buy itself opens the pdf file just fine
However, when I add this it gives me the parse error:
can anyone tell me what I am doing wrong.
Thanks
Rachael
I am trying to output a pdf file within a php file. The files are within a password protected area that uses an SQL database to store username/password/userlevel, and sets a cookie that expires upon clossing the browser. I am trying to get so that they can open the pdf files while in their individual customerarea, but I do not want them to be able to bookmark, or type the file path directly into the browser, and pull the pdf file up. I want them to have to go through the login screen like they would have to to get to any other password protected page.
This is the code I am using. It works fine until I try to add the if cookie set string. When I add this I keep getting a parse error message.
Here is the code I am trying to use:
ATTN: this buy itself opens the pdf file just fine
Code: Select all
<?php
header('Content-type: application/pdf');
readfile('Due List.pdf');
?>Code: Select all
<?php
if($HTTP_COOKIE_VARSї'loged'] == 'yes') {
if($HTTP_COOKIE_VARSї'user_level'] == '5') {
$sql = "SELECT * FROM ".$prefix."_users where activated='0'";
$result = $db->query($sql);
$total = $db->num($result);
$num = "<a href="users.php">$total</a>";
header('Content-type: application/pdf');
readfile('Due List.pdf');
?>Thanks
Rachael