Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i want only to show a pdf with onload or something else. but..

Status
Not open for further replies.

alico1233

Programmer
Jan 12, 2005
5
TR
Hi,
my goal is to show pdf documents after controlling password. I use classical form for u/p,and want to take the nema of the pdf, which should open, from address bar,in order net to create multiple phps.
the problem with opening pdf: I was useing:
?>
<BODY onLoad="location.replace('../directory/example.pdf')"></BODY>
<?
It works, but now I use:

$variable=$_GET['name'];
?>
<BODY onLoad="location.replace($variable)"></BODY>
<?

It doesn't work. comes an error page.the error is undefined variable: $variable. However when I echo $variable, the right directory name comes,namely GET works properly.

Please help
 
Try

[tt]<BODY onLoad="location.replace(<?php echo $variable; ?>)">[/tt]

Regards


Jakob ;-)
 
thanks a lot but this time I see only

it does not take $variable as anormal string

is there a way to open this pdf files in php without using http and onload?
 
You can try something like this (I just did and it works OK):
Code:
<?php
  if (($_POST['auth'] == 1) && ($_GET['name'] <> ""))
  {
    header("Location: [URL unfurl="true"]http://".$_SERVER[/URL]['HTTP_HOST']."/test/pdfs/".$_GET['name']);
  }
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>?name=test.pdf" method=post>
<input type=hidden name=auth value=1>
<input type=submit value=Click!>
</form>
You'll have to adjust it based on your authentication, but you can use the header() to auto-load a page. The PHP block has to go right at the top of your file - there can be no output from the file whatsoever before the header() is issued.

Good luck!

Marc
 
Yes, it works!

Thanks a lot Marc, and also Jakob for your helps.

See you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top