Additionally, Netfirms allows a way to login the database with users and passwords created outside of the database. This gives them read / write or just read access.
This is common with most hosts. And even that "users" login and access permissions information is still stored in a the database. That fact is just likely not visible to you.
So basically, I am using this way to retrieve a username / password from the person in order to see if they have read / write access or just read acesss. If they put in the correct user/pass then they will have access to the database.
Yep, have your code check the info they entered if it matches and they have the permission to have read / write access you then include the database connection code that has the user with the read / write access. Otherwise if they only have read access then you include the code that connects using the read only user.
I should note that when they are logging in you will need to check their info using the read only access user. And at that time you need to store there access permission level in the $_SESSION super global so that no mater what page they are on it will know their access level without having to request it. And then check the access level on every page load to see which connect code you should use.
if (isset($_SESSION['access'] )) {
if ($_SESSION['access'] == 1) {
// connect to read / write user
mysql_connect($location, $username, $password);
}
else {
// connect to read only user
mysql_connect($location, $username, $password);
}
}
else {
echo 'ERROR: You do not have permission to view this page';
}
Or is it possible to create users in a table that has permission to other tables in the same database.
Yes is the general answer.
But, for the sake of clarity, putting a user info into a table doesn't effect the users access to other tables in the database, it is just information that means nothing to the database. The information gets meaning when you use it in your code. So you could use one table to store the user login info and in that table or a second table you could store info on which other tables a user has access to and then your code does all the work in granting or blocking access.