954,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to Add code to enable logged in users to download pdf files or any other files?

What code do i add in order to let logged in users to download pdf files or any attachments i would like them to download?


<?php
if (isset($_POST['login'])) {
$query = "SELECT * FROM users WHERE uuser='".$_POST['user']."' AND upass='".$_POST['pass']."'";
$result = mysql_query($query)
or die(mysql_error()."
error: failed to execute query $query");
if ($myrow = mysql_fetch_array($result)) {
$_SESSION['web_user_id'] = $myrow['useqn'];
} else {
$err_msg = "Invalid Login";
} // end if
} // end if

if (isset($_GET['logoff'])) {
session_destroy();
} // end if

if ($_SESSION['web_user_id']) {
?>


Previous Orders
Log off



<?php
include "scripts/user/disp.php";
} else {
?>

<?php echo $err_msg;?>

Login

User Name

Password




<?php
} // end if
?>

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

If they have logged in you could create a session that says that the user is logged in, and then on the other page, if the session exists, you could show the download links?

Of course this is just a simple suggestion, I have yet to mention security etc. ;)

minitauros
Junior Poster
109 posts since Apr 2011
Reputation Points: 36
Solved Threads: 17
 

The problem is I am new to this and this is not my coding. It is another developers work.

Is there no piece of code to add to indicate a link in the current code i posted earlier?

Security???

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

while starting session

$_SESSION['is_logged_in']['true']

and on download page, you can check

if($_SESSION['is_logged_in']=='true')
{
 do some download work
}
baig772
Junior Poster
123 posts since Mar 2011
Reputation Points: 29
Solved Threads: 6
 
if(isset($_SESSION['web_user_id'])){
     links to downloadable pdf
}
vaultdweller123
Posting Pro
554 posts since Sep 2009
Reputation Points: 42
Solved Threads: 75
 

Hi

Thanks!

COuld someone please show me where to insert your guys code in the code I provided...

I am new to this and this is the previous web masters files I am working with...

INF-P
Newbie Poster
16 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You