Forum Moderators: coopster

Message Too Old, No Replies

Dealing with 2 databases

         

Gilead

7:39 pm on Oct 19, 2011 (gmt 0)

10+ Year Member



I'm fairly new to php and mysql. The situation is I have two areas- one an admin area and one a member area.
One database handles the login: first name, last name, password, group, etc.

The second database has different details, but must match up with a contact manager, so I cannot change it.

Once you've logged in, I wanted details available to the member, by pulling them from the second database without making any changes. My thought was to use one of the fields from the second in the first as a cross reference. How do I make sure that the right contact id is used to pull up the current user's details?

The admin section enables admins to add users, send email, delete, unban, etc. They will also be able to change details in the second database.

Does this make sense?
Thanks for the help.

abushahin

8:04 pm on Oct 19, 2011 (gmt 0)

10+ Year Member



have two different forms to login, member login and admin login once logged in create different session names for each type of user. Now all you have to do is check the session name on each page so that member user isnt able to go to admin pages. hope that helps

jones_nash

1:41 pm on Oct 24, 2011 (gmt 0)



That is one of the reasons that I started using PHP code generators, I dont want to waste time on this kind problem.

I personaly use scriptcase and we can do this validation automatically, it will generate a security module and this will filter this kind of information to you without need of you type a single line of code.

If you dont use PHP code generators I strongly recomend you to starting use one.

Gilead

2:23 pm on Oct 24, 2011 (gmt 0)

10+ Year Member



I tried scriptcase, but it didn't give me what I was looking for. Any other thoughts?

paperso

3:47 pm on Oct 24, 2011 (gmt 0)

10+ Year Member



I don't know if I understand your situation well but I think you can do this:

1. After successfully login, register cookies.
2. Match that cookies in the second database to pull their own details.

mysql_query ( "SELECT * first_db WHERE user_id = $_COOKIE['id'] AND user_status = 'admin'" )

// if admin redirect to the admin panel

// if status is regular, redirect to front page.

Gilead

8:17 pm on Oct 26, 2011 (gmt 0)

10+ Year Member



@Jones_Nash
The main problem I had was that scriptcase could not connect to my local mysql database even when the webserver was running. It also seemed to be a collection of prefabricated applications, none of which I was really looking for at the time. I appreciate the effort. I also contacted them concerning the issue I was having. To date, they have not responded.

Habtom

4:33 pm on Oct 29, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The solution for your problems could lie on cookies or sessions. $_COOKIES['ADMIN_ID'] can contain your admin ID or whatever you call it, if the admin is logged in. And a similar cookies for the second login.

PHP code generators

There is always going to be a limit to how far you can be flexible with generators. Plus, it can never be a full replacement to learning PHP.