Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 03-01-2008, 12:24 PM   #1 (permalink)
 
Banned

Join Date: Oct 2006

Posts: 81

williwaw

Default PHP If...Else Help

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.

Code:
    <?php

    // Define your username and password
    $username = "name";
    $password = "pass";

    if ($_POST['txtUsername'] != $username || $_POST['txtPassword'] != $password) {

    ?>
    
//HTML Form resides here

    <?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

williwaw is offline  
Old 03-01-2008, 03:16 PM   #2 (permalink)
 
Banned

Join Date: Oct 2006

Posts: 81

williwaw

Default Re: PHP If...Else Help

Well it's not PHP, but it does solve the problem...
Code:
<script language="javascript">window.location='#';</script>
Thanx all,
Williwaw
williwaw is offline  
Old 03-02-2008, 02:59 PM   #3 (permalink)
CrazeD's Avatar
 
Wizard Techie

Join Date: Feb 2006

Location: Maine

Posts: 3,686

CrazeD will become famous soon enough

Send a message via AIM to CrazeD Send a message via MSN to CrazeD
Default Re: PHP If...Else Help

That's not secure at all. They can just type the URL to the .pdf into the browser and access it.

You should use .htaccess instead.
__________________

Need website help? PM me!
CrazeD is offline  
Old 03-02-2008, 03:41 PM   #4 (permalink)
 
Banned

Join Date: Oct 2006

Posts: 81

williwaw

Default Re: PHP If...Else Help

If they know the path of the document, sure they can type it in. I don't need it to be bomb proof, I just need loose control over the laymen to the access of the document.

Thanks for your help,
Williwaw
williwaw is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Coding Pat_pet Programming Discussions 8 03-26-2008 06:41 AM
PHP request not responding Bengal313 Programming Discussions 3 02-13-2008 06:39 PM
New Site Project - Flash + PHP + MySQL + CSS theone_trent Web Graphics, Design, Digital Images 2 06-30-2007 01:12 PM
PHP 2-player game? thejeremy Programming Discussions 4 04-09-2007 06:01 PM
Remote file access w/ IP + PHP? thejeremy Programming Discussions 2 04-04-2007 05:24 PM