SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Specific Client Pages Login

    Hi,

    I want to be able to login a user to a specific page that shows only their details. I want to use Dreamweaver MX, PHP and MySQL. I understand how to login users and how to restrict access, but can I just login the user to a page that shows their unique information,

    Many thanks in advance,

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Use the login to select their details from the database using session variables from the login script.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, you may have to elaborate, do I put the web page in the database, or can I have a generic page that pulls data from the database regarding the particular client that is logging in.

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    sc
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can use a generic page that pulls the info that corresponds with the user's login data. For instance you could use:
    Code:
    $sql = "SELECT * FROM Users WHERE Username = '$loginName'";
    That would pull all the data for the specific user, and you would just have to display it as you want

  5. #5
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, let me see if I have this right

    $sql is the variable that will hold all the data pulled from the database and $loginName is the variable from the user login.

    Would I set the variable at the start of the page.

    But I thought I could use the parameters part of dreamweaver. When setting the page to go to after login, couldn't I choose say details.php and then in the parameters setting, set it to pull information using the username dynamic source.

    Is that clear, but from what I know, which is not a great deal of php, but I understand DMMX2004, it seems logical.

    Is that right?

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Nick, the way it could work is this:

    1./ the user logs in from the login form.
    2./ the login is checked and verified using your existing login sql query (I hope!)
    3./ The query used to log the person in can also be used to get the rest of their details and display them on the page.

    I can't remember of the top of my head how dreamweaver does this in it's dynamic context as I stopped using the programmes own procedures a while ago.

    HTH

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope so, I am going to have a go at it and see what happens

  8. #8
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I not set a if/else function at the start of the page.

    EG

    ClientA.php

    If username = clientA login, else go to failure.php

  9. #9
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Your best bet is to use sessions.
    PHP Code:
    #after login
    $_SESSION['logged'] == 'Y'
    Then on restricted pages...
    PHP Code:
    session_start();

    if(
    $_SESSION['logged'] == 'Y') {
    } else {
    header("Location: error.php");

    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  10. #10
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can I pass the client_id from the login screen to the client area page?

  11. #11
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I had solved this and at home it worked, I made notes to myself based on what I did, took it to work with me and its not working. The code:

    login page:

    PHP Code:
    <?php require_once('../Connections/connNative.php'); 
    # start the session
    session_start();

    # define some useful variables
        
    $redirect_success 'clientArea_test.php';
        
    $redirect_failure 'failure_test.php';
        
    # if the form has been submitted
        
    if (isset($_POST['mm_login'])) {
            
    mysql_select_db($database_connNative$connNative);
            
    $loginUsername $_POST['username'];
            
    $password md5($_POST['pwd']);
            
    # run login query
    # select the field you require and the fields to be registered as session variables
        
    $login mysql_query("select client_id, username, pwd from clients where username = $loginUsername' and pwd = '$password'") or die (mysql_error());
        
    $login_rows mysql_fetch_assoc($login);
        
    $login_check mysql_num_rows ($login);
            if(
    $login_check >0) {

    # now we can register the session variables
    $_SESSION['client_id'] = $login_rows['client_id'];
    $_SESSION['username'] = $login_rows['username'];

    # NOTE. you can only register the field you have requested from database

    # direct as appropriate
    header ("Location: "$redirect_success);

    } else {
    header ("Location: "$redirect_fail);
    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Login Client</title>
    </head>

    <body>
    <form name="clientLogin" id="clientLogin" method="POST" action="<?php $_SERVER['../PHP_SELF']; ?>">
      <table width="391" border="0">
        <tr>
          <td width="184">Username</td>
          <td width="197"><input name="username" type="text" id="username" /></td>
        </tr>
        <tr>
          <td>Password</td>
          <td><input name="pwd" type="password" id="pwd" /></td>
        </tr>
        <tr>
          <td><input type="submit" name="Submit" value="Login" /></td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form>
    </body>
    </html>
    client area:

    PHP Code:
    <?php require_once('../Connections/connNative.php'); 

    # start the session
    session_start();

    # define variables from the session variables
    $client_id $_SESSION['client_id'];

    mysql_select_db ($database_connNative$connNative);

    # run the query to get the info from the database
    $client_sql mysql_query("select * from clients where client_id = '$client_id'") or die (mysql_error());
    $client_rows mysql_fetch_assoc($client_sql);

    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Client Area</title>
    </head>

    <body>
    <? echo $client_rows['client']; ?>
    </body>
    </html>
    Many thanks in advance.

  12. #12
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone?? I'm quite desperate for some help. I really would appreciate it.

  13. #13
    SitePoint Zealot Krieger's Avatar
    Join Date
    Dec 2003
    Location
    Nevada - USA
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm.

    Upon a quick glance, this appears as though it would be a problem:
    Code:
    <form name="clientLogin" id="clientLogin" method="POST" action="<?php $_SERVER['../PHP_SELF']; ?>">
    The docs do not list the relative reference [../PHP_SELF] as a valid value for the superglobal $_SERVER[].
    Verwüstung rufen und des Krieges Hund' entfesseln!

    My Site
    My first php/MySQL project -->Thanks Sitepoint members

  14. #14
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure, i'm wondering if it is because there seems to be no login code, i'm thinking its too obvious though.

  15. #15
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Nick,
    There is no hidden field called mm_insert which you are calling in this line...
    if (isset($_POST['mm_login'])) {


    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  16. #16
    SitePoint Addict jough's Avatar
    Join Date
    Sep 2001
    Location
    You have moved into a dark place. It is pitch blac
    Posts
    248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, remember, PHP_SELF will use the current page, so the var is $_SERVER['PHP_SELF'].

    If you need to post to a page a level up, you should be able to set your action="../index.php" or wherever your script processor php file is located.
    My Dynamic Site in Action:
    Poetry X Poetry Archive

  17. #17
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fixed it, well Spike pointed out a glaring error that I missed, some days I just have no logic. Is there anyway of restricting access to this page without using dreamweavers built in behaviour?

  18. #18
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,788
    Mentioned
    151 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by spikeZ
    Your best bet is to use sessions.
    PHP Code:
    #after login
    $_SESSION['logged'] == 'Y'
    Then on restricted pages...
    PHP Code:
    session_start();

    if(
    $_SESSION['logged'] == 'Y') {
    } else {
    header("Location: error.php");

    Use this code....

    SpikeZ
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  19. #19
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Port Sunlight
    Posts
    815
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Spike.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •