Page 1 of 1

Outputting a PDF File through a PHP File in Protected Area

Posted: Wed Jun 16, 2004 4:53 pm
by rache2000
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

Code: Select all

<?php
header('Content-type: application/pdf');

readfile('Due List.pdf');
?>
However, when I add this it gives me the parse error:

Code: Select all

<?php
 if($HTTP_COOKIE_VARS&#1111;'loged'] == 'yes') &#123;
   if($HTTP_COOKIE_VARS&#1111;'user_level'] == '5') &#123;
      $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');
?>
can anyone tell me what I am doing wrong.

Thanks
Rachael

Posted: Wed Jun 16, 2004 4:57 pm
by markl999
You never close your if's , i.e they are both missing the closing }