Jump to content

PHP If...Else Help


williwaw

Recommended Posts

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

thLavaLampSmall_anim.gif

 

Link to comment
https://forums.phpfreaks.com/topic/93893-php-ifelse-help/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.