1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Login Systems to profile page????

Discussion in 'General Programming Chat' started by blackhatdamo, Feb 13, 2013.

  1. blackhatdamo

    blackhatdamo Registered Member

    Joined:
    Apr 6, 2012
    Messages:
    86
    Likes Received:
    27
    Location:
    A dark place
    Hi everyone, I would like some advice if possible,

    I am after creating a manual system that allows a user to access files on a page created by me,

    The Scenario:

    The Client contacts me and I set up their username and password which takes them to a page with their files on that I have created manually. Clients cannot view the pages of other clients so each would have a page like domain . com/client_name.

    I know each page will have to check that it has been redirected from the login ( im guessing by checking the session cookie).

    Is there an easy way of coding this (or a tutorial) or a wordpress plugin that will do this?? I have looked around but everything points to the client registering which I do not want.

    I have a little knowledge of PHP and can create a login system with registration but cannot do what I want :(

    Any help would be greatly appreciated.
     
  2. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,906
    Likes Received:
    1,938
    Here's a simple login page for a single user:

    PHP:
    <?php
    <?php
    session_start
    ();
    // Check For Login Attempt
    if (isset($_POST['login'])&&($_POST['login']==1)){
        if((
    $_POST['username']!=$admin_user)||($_POST['password']!=$admin_pass)){$logged_in=0;}else{$_SESSION['username']=$_POST['username'];$_SESSION['password']=$_POST['password'];$logged_in=1;}
    }else{
        if(isset(
    $_SESSION['username'])){if(($_SESSION['username']!=$admin_user)||($_SESSION['password']!=$admin_pass)){$logged_in=0;}else{$logged_in=1;}}else{$logged_in=0;}
        }
    // If Not Logged In Display Login Form
    if ($logged_in==0){
        echo 
    "<center><form action='' method='post'><table border='0' cellpadding='4' cellspacing='0'>";
        echo 
    "<tr><th colspan='2'><h2>Login</h2></th></tr>";
        echo 
    "<tr><td align='left'>Username:</td><td><input type='text' name='username' /></td></tr>";
        echo 
    "<tr><td align='left'>Password:</td><td><input type='password' name='password' /></td></tr>";
        echo 
    "<tr><td colspan='2'><div align='center'><input type='hidden' name='login' value='1' />";
        echo 
    "<input type='submit' name='submit' value='Login' /></div></td></tr></table></form><br />";
        echo 
    "</center>";
        echo 
    $footer;
        exit;
        }
    // Display Members Page Below

    To change to members make sure to retrieve / check DB values for username / password & display content that is available to that user only & check that they are logged in on each page.
     
    • Thanks Thanks x 1
  3. blackhatdamo

    blackhatdamo Registered Member

    Joined:
    Apr 6, 2012
    Messages:
    86
    Likes Received:
    27
    Location:
    A dark place

    Thank You, this is much appreciated, from what I'm gathering this script will be checking if ' admin ' is logged in. I can check db values for users but where each user gets there own 'page' i'm not sure how to do as each page will be created manually and populated with content by me as every members content will be completley different :/

    is there anything along these lines anywhere?

    I greatly appreciate your help :)
     
  4. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,906
    Likes Received:
    1,938
    You will need to have some basic PHP knowledge to do the rest but an example would be:
    PHP:
    <?php
    $sql 
    mysql_query("SELECT * FROM table WHERE userid='".$_SESSION['username']."'");
    while(
    $row=mysql_fetch_array($sql)){
    echo 
    $row['thing_name']."<br>".$row['somethingelse'];
    }
    ?>
    It all depends on how you are storing data in your database as to how you can show the user what details you want to show them. You will 100% need basic knowledge at a minimum for PHP / MySQL so that you can complete this though, bodging / getting others to do something like this will end up in endless fee's for updates when you need changes made.
     
  5. blackhatdamo

    blackhatdamo Registered Member

    Joined:
    Apr 6, 2012
    Messages:
    86
    Likes Received:
    27
    Location:
    A dark place

    I understand what your saying, I have basic knowledge iv'e just completed a php module at uni but the tutor was crap and i know more about his personnal life than i do php.

    I can make basic login scripts and query databases ( using mysql) . If each page for each user holds different files, am i best seeing which user is logged in and then pulling their files by matching up file id's to user id's?

    how would I manually upload these files for them myself and match them to the users and also how would i match file id's to user id's? I tried this before and was completly unsuccesful :(

    I can also display files (images) from a folder, but the users files are pdf's and .doc files
     
  6. gimme4free

    gimme4free Executive VIP Jr. VIP Premium Member

    Joined:
    Oct 22, 2008
    Messages:
    1,906
    Likes Received:
    1,938
    At the point of uploading data / files you should assign them to a database with the user's ID & then use .htaccess to block access to the folder & retrieve the files via PHP after querying the DB to confirm that the user is allowed access to the requested file.
     
  7. blackhatdamo

    blackhatdamo Registered Member

    Joined:
    Apr 6, 2012
    Messages:
    86
    Likes Received:
    27
    Location:
    A dark place
    so I can upload the files to a folder and store the file path in a database that will display them to screen once the query is authenticated. How do I assign a users ID to the files?

    Is there a wordpress plugin or an off the shelf script that can do this?

    I am sorry for being such a pain, but I'm more of a front-end developer.

    Many Thanks
     
  8. jaismin

    jaismin Newbie

    Joined:
    Feb 26, 2013
    Messages:
    11
    Likes Received:
    1
    Location:
    chandigarh
    Home Page:
    [FONT=&quot]When you uploading files than you should assign them to a database with the user's ID & then use .htaccess to block access to the folder [/FONT]