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()."<br><b>error</b>: failed to execute query <i>$query</i>");
   if ($myrow = mysql_fetch_array($result)) {
      $_SESSION['web_user_id'] = $myrow['useqn'];
   } else {
      $err_msg = "<font color='red'>Invalid Login</font>";
   } // end if
} // end if

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

if ($_SESSION['web_user_id']) {
?>
<br><br><h2>Previous Orders
<p align='right'><a href='?page=Login&amp;logoff' title=''>Log off</a></p></h2>
<?php
   include "scripts/user/disp.php";
} else {
?>
<center>
   <?php echo $err_msg;?>
   <form method='post' action='?page=Login'>
      <fieldset style='padding: 10px; text-align: left; width: 200px;'>

         <legend>Login</legend>

         <label>User Name</label><br />
         <input type='text' name='user' /><br />
         <label>Password</label><br />
         <input type='password' name='pass' /><br />
      </fieldset>
      <br /><input type='submit' name='login' value='login' /> <input type='button' name='register' value='register' onclick="window.location='?page=Registration'" />
   </form>
</center>
<?php
} // end if
?>

Recommended Answers

All 5 Replies

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. ;)

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

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
}
if(isset($_SESSION['web_user_id'])){
     links to downloadable pdf
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.