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 Link to comment https://forums.phpfreaks.com/topic/93893-php-ifelse-help/ 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 } ?> Link to comment https://forums.phpfreaks.com/topic/93893-php-ifelse-help/#findComment-481107 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 Link to comment https://forums.phpfreaks.com/topic/93893-php-ifelse-help/#findComment-481114 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. Link to comment https://forums.phpfreaks.com/topic/93893-php-ifelse-help/#findComment-481117 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.