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?

Recommended Answers

All 7 Replies

How about you post some code so we can see what you're talking about...

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.

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

commented: correctly said +1

sunwebsite, how would i do that?

Member Avatar for diafol

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...)

[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.

Member Avatar for diafol

>> superfluous id

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.