0

I have a login script that people use to register and login. I also have a contacts page where people can add contacts. Now how do i make it so the people that are logged in can add their own contacts that nobody else can see, only them when they log in?

5
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by diafol
0

It's very simple. If you use well defined database table for each registering user. When they login you get it from table and display it on the page.

0

Are the contacts other users or any random person they happen to want to add? This will determine how you develop the DB structure.

Either way, though, you'll need a contacts table.

For contacts = members only:

id [PK, int]
user_id [int]
contact_id [int]

For contacts = general contacts:

id [PK, int]
user_id [int]
(and all the fields required, e.g. firstnames, surname, title, email, mobile...)

1

[rant]

use sessions to do login and logout pages.. and contact display page only for logged in members..

How does something like this get upvoted?!

-OP you should use PHP to handle your login and logout. <- I expect this to be upvoted as well.
[/rant]

Now in all seriousness, ardav is the only here who has posted anything of any real value.
I agree with both of his suggestions for structuring this, with the exception of:

For contacts = members only:

id [PK, int]
user_id [int]
contact_id [int]

I would drop the id column as a user (user_id) would never be joined to the same contact (contact_id) more than once. So user_id, contact_id would form a composite primary key making the id superfluous.

0

>> superfluous id

Yes quite right. Force of habit. Anyway, I'll upvote you. BTW - love your avatar. You deserve an upvote just for that.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.