0

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

Edited by Dani: Formatting fixed

4
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by INF-P
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. ;)

0

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

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
}
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.