SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist jazztie's Avatar
    Join Date
    Mar 2001
    Location
    the Netherlands
    Posts
    519
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm looking for a way to do the following:

    I have two tables: 'employee' with e.username and e.userid (along with a lot of other info) and 'password' with p.userid and p.password.

    UserID is the link between table 'employee' and table 'password'. p.userid = e.userid

    I want to have an authentication page where people type in their username (e.username) and their password. (p.password).

    So, I have to combine the two tables in one query. Could someone help me?

    I have the two seperate queries already, but I don't know how to combine them:

    SELECT e.userid
    FROM employee
    WHERE e.username = $PHP_AUTH_USER

    SELECT *
    FROM password
    WHERE p.password = $PHP_AUTH_PW and p.userid = e.userid

    Thanx
    Jazz
    Last edited by jazztie; Apr 19, 2001 at 01:59.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    UK
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not 100% this will work, since I just did a quick test, and so haven't got much data to work on.

    Try:

    PHP Code:
    SELECT FROM employee,password WHERE employee.e.username $PHP_AUTH_USER and
      
    password.p.password $PHP_AUTH_PW and password.p.username employee.e.username
    That should work, as a really raw SQL alternative. I believe you can join tables, but I am not entirely sure of the outcomes of that, so it wouldn't be right to lead you astray..

    James
    Last edited by imajes; Apr 19, 2001 at 02:08.

  3. #3
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why do you need to make 2 seperate tables?
    it would be nice and good approach to keep information in one table
    employees table
    userid
    username
    password

    but answer to your question is
    SELECT e.userid, e.username,
    FROM employee e, password p
    WHERE e.username = $PHP_AUTH_USER AND
    p.password = $PHP_AUTH_PW AND
    p.userid = e.userid


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
  •