williwaw Posted March 1, 2008 Share Posted March 1, 2008 Hi all, I am trying to password protect a .pdf document. I have it working "pretty much" but rather than have a link that needs to be clicked after the name/pass is entered in the "Else..." statement, I have been trying to have the .pdf document open "automatically" without the link. <?php // Define your username and password $username = "name"; $password = "pass"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> //HTML Form resides here...just took it out for ease of reading <?php } else { ?> //This is where I would like the document to //"automatically" open. <p><a href="doc.pdf">SURVEY</a></p> <?php } ?> Thanks for your help and I am going to go and open my PHP book. I will post an answer if I get one. Cheers, Williwaw Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted March 1, 2008 Share Posted March 1, 2008 Im assuming u just need to redirect the user to the pdf file... <?php // Define your username and password $username = "name"; $password = "pass"; if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) { ?> //HTML Form resides here...just took it out for ease of reading <?php } else { ?> //This is where I would like the document to //"automatically" open. <p><script language="javascript">window.location='doc.pdf';</script></p> <?php } ?> Quote Link to comment Share on other sites More sharing options...
williwaw Posted March 1, 2008 Author Share Posted March 1, 2008 This would be true...thank you for your help Quote Link to comment Share on other sites More sharing options...
QuietWhistler Posted March 1, 2008 Share Posted March 1, 2008 header( "Location: doc.pdf" ); if you want to use PHP. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.