FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » login validation from 2 tables in same database
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
login validation from 2 tables in same database [message #184800] Mon, 03 February 2014 04:03 Go to next message
hujan is currently offline  hujan
Messages: 1
Registered: February 2014
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
Hi, how to do one log in form but being use by 2 different entities/tables in the same DB?

Also, each table have different number of columns. Below is my table fields:

user [id(PK), profile, name, gender, dob, contact, addr1, email,username, password]

student [reg_no(pk), s_name, s_gender, s_ic, s_dob, s_contact, s_email, s_addr1, s_addr2, country, s_dept, s_post, username, password]
Re: login validation from 2 tables in same database [message #184805 is a reply to message #184800] Mon, 03 February 2014 07:47 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 03 Feb 2014 03:03:28 -0600, hujan wrote:

> Hi, how to do one log in form but being use by 2 different
> entities/tables in the same DB?

Logging in to the website is usually handled at the php session level
between the web server and the client browser.

Logging in to the database usually happens once for each request, often
involving an included file that contains the db password and which sits
outside the webroot of the server.

If you wish to access multiple tables in the same database, you only need
to log in to the database once in the php request server that accesses
the database. Just don't close the db connection until you've made all
the db requests needed to erve the http request.

> Also, each table have different number of columns. Below is my table
> fields:
>
> user [id(PK), profile, name, gender, dob, contact, addr1,
> email,username, password]
>
> student [reg_no(pk), s_name, s_gender, s_ic, s_dob, s_contact, s_email,
> s_addr1, s_addr2, country, s_dept, s_post, username, password]

Your data needs some normalisation. If a student is also a user you're
storing a lot of duplicated data.

Think along the following lines:

Person: id, profile, name, gender, dob, contact, addr1, email, country

User: id, username, pw

Student: reg_no, id, dept, post

A user is a person who also has data in the user table
A student is a person who also has data in the student table
A student user is a person who also has data in the user and student
tables

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Re: login validation from 2 tables in same database [message #184808 is a reply to message #184805] Mon, 03 February 2014 08:18 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
Denis McMahon wrote:

> hujan wrote:
>> Also, each table have different number of columns. Below is my table
>> fields:
>>
>> user [id(PK), profile, name, gender, dob, contact, addr1,
>> email,username, password]
>>
>> student [reg_no(pk), s_name, s_gender, s_ic, s_dob, s_contact, s_email,
>> s_addr1, s_addr2, country, s_dept, s_post, username, password]
>
> Your data needs some normalisation. If a student is also a user you're
> storing a lot of duplicated data.

Not only that: I would recommend also breaking up the name fields to
firstname, mi, lastname and adding city, state, postcode fields.
Otherwise, the "combined" fields are quite useless for searching.

Data gatherers will use: [John Smith] or [Smith, John A.] if you give
'em a chance...

--
-bts
-This space for rent, but the price is high
Re: login validation from 2 tables in same database [message #184811 is a reply to message #184808] Mon, 03 February 2014 18:13 Go to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
On Mon, 03 Feb 2014 13:18:25 +0000, Beauregard T. Shagnasty wrote:

> Denis McMahon wrote:
>
>> hujan wrote:
>>> Also, each table have different number of columns. Below is my table
>>> fields:
>>>
>>> user [id(PK), profile, name, gender, dob, contact, addr1,
>>> email,username, password]
>>>
>>> student [reg_no(pk), s_name, s_gender, s_ic, s_dob, s_contact,
>>> s_email,
>>> s_addr1, s_addr2, country, s_dept, s_post, username, password]
>>
>> Your data needs some normalisation. If a student is also a user you're
>> storing a lot of duplicated data.
>
> Not only that: I would recommend also breaking up the name fields to
> firstname, mi, lastname and adding city, state, postcode fields.
> Otherwise, the "combined" fields are quite useless for searching.
>
> Data gatherers will use: [John Smith] or [Smith, John A.] if you
> give 'em a chance...

If contact is meant to be a phone number, he may want work / home / cell
fields as well.

--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: sendmail from localhost is driving me crazy!
Next Topic: user resgiartattion form
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Dec 16 06:15:51 EST 2017

Total time taken to generate the page: 0.00668 seconds