Being in the same database doesnât make them related.
I could put a âbaseballâ table and âaliensâ table in my database, it doesnât make them related.
If, however, I can say that either:
1: The âreported_byâ field in the aliens table is tied to the ânameâ field in the baseball table;
or
2: There is a third table, such as âbaseball_aliensâ, that has a field âparkâ that is tied to the baseball table, and also has a field âencounter_idâ that is tied to the aliens table.
Then I can say there is a relationship between the two tables. In other words, using fields that are tied together, I can draw a line from one table to the other, even if it requires one (or more) âhopsâ through additional table(s).
Also itâs unclear to me what you intend this scipt to do.
It appears a bit like some kind of log-in, but then doesnât make much sense as one, as it just forwards to the same page regardless of input.
I admit, the PHP feels off to me. (besides the syntax, is the admin not a user? is it wise to have the admin username admin? why not have a single redirect after the conditionals?)
Any, the question is how to use information from a single form in two different queries. Iâm not understanding the problem. eg. a form with a single
<input type="text" name="username" ...
should submit a value that the action file can access with $_POST["username"] and use as many times as it needs to.
Please correct me if Iâm missing something about what youâre asking.
Based on the form supplied username input:
is the user in the user table?
is the user in the admin table?
redirect to appropriate index page
IIRC, most log in permissions designs Iâve seen have a table with âusernameâ, âpasswordâ, âroleâ fields where the âroleâ field would specify âuserâ, âmoderatorâ, âauthorâ, âadminâ etc. Permissions are often passed around in SESSION variables. eg.
Then, no matter what file is loaded, it can test for the SESSION values and do / not do, display / not display whatever.
Is this something you are just beginning to put together and can change itâs design, or is this something youâre committed to using and need to figure out how to work with it?
It would be better to do that, and have a single table IMO. Apart from anything else, it makes it slightly less complex when a new user signs up, as you only have to check in a single table to see if their username / email / whatever you use to identify them is not already in the table.
Sorry I wasnât clear. By âsomethingâ I meant code outside of your control. By âcommittedâ I meant a need to use someone elseâs code, not that you needed login / permission control.
Anyway, if you can change the database design I am fairly certain that in the long run you will find it easier to have a single âuserâ table with a âpermissionsâ field.
Unless you want to query the database every HTTP request (you donât), I think SESSIONs are a good choice for passing around the more important values such as admin or not.