Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Is there a free script which I can use to:

Share some PDF with my partners. But i need the user to reach only those PDFs which they have privileges for. So I need:

  • login script with registration (i will make the registration if need. So registration function will public)
  • every user should have their own member area
  • I will upload PDFs to the specified user areas
  • when my partners sign in they can see only those PDFs that they have privileges for
share|improve this question
    
Skydrive would be a lot easier. –  ZippyV May 9 '12 at 9:40
1  
You can also try Google Docs for this type of thing. Would save you the trouble of setting this up yourself. –  Sherwin Flight May 10 '12 at 4:14
add comment

2 Answers

I would recommend using Google Docs for this.

In broad strokes: If you insist on creating this feature yourself, you would need to store your user info (user ID, Password, etc) in a table in a database.
Then you'd need a second table which has the info on the PDF files (link, name, which user ID's have access to it).
When a user logs in you would run a query to authenticate them with their user ID and password from the users table, and checks at the same time which PDF files are accessible to that user.

Your login form would look something like this:

<form name="login" action="login.php" method="post">  
  User ID: <input type="text" name="user" /><br />  
  Password: <input type="text" name="pass" /><br />  
  <input type="submit" value="Sign In" />  
</form>

Your login.php file would have something like this:

<?php  
  $query = mysql_query("SELECT userID, password FROM users_table WHERE userID = '$_POST['user']'");  
  $get_user = mysql_fetch_array($query);  
  if ($get_user['password_column'] == $_POST['pass']){  
    //user is logged in!  
  }  
  else {  
    //invalid username or password  
  }  
?>

Your PDF file info table would have to have at the least the PDF file name and which users are allowed to view/download that file. Once the user is logged in you would run a query which looks something like this (assuming you have the user name stored in the PHP variable $user:

SELECT * FROM pdf_table WHERE MATCH(allowed_users_column) AGAINST ('$user')  

So to make a long story short: it is very possible to do this. The code I've posted is rudimentary and basic at best, but it should give you a general idea of how to accomplish this if you cannot use a service like Google Docs for this.

share|improve this answer
    
If you implement this make sure you escape properly all fields coming from the form. Also a good idea would be to encrypt the password. –  milo5b Jul 22 '12 at 10:44
add comment

UserCake is an open source PHP user management script which has registration features and user group features which you could use to manage who has access to which PDF files.

http://usercake.com/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.