login validation from 2 tables in same database [message #184800] |
Mon, 03 February 2014 09:03 |
hujan
Messages: 1 Registered: February 2014
Karma: 0
|
Junior Member |
|
|
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 12:47 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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 13:18 |
Beauregard T. Shagnas
Messages: 154 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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 23:13 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
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
|
|
|