Working with two Tables in database Php?

The essence of the question is: is there a website on which people purchase a subscription. There are 2 types of membership and depending on the choice users are given access to certain pages. To solve this problem I decided with help of 2 tables and signup signup1. Each contains the field user_id username password.
A person buys a subscription and it comes depending on the purchase the login and password of the corresponding table. Connect to one table on submit I could do, it looks like this:
But how to connect the second table here generally is not present. That is, it should approximately be: if one table has no match, the handler must check the second and give the answer.
Unfortunately PHP is not strong, searched the Internet nadybal like this to happen you need to do so:

But it doesn't work. Ask the Board summarized the people.
March 19th 20 at 09:24
1 answer
March 19th 20 at 09:26
The title of the question "Working with two Mysql database in Php?" is not correct. You use one database but two tables.
In fact it is wise to use ONE table. And in it add a field , something like
subscription_type. Then you won't have to look first at one and then at another table. And if you have another subscription type, you will be a third table to create and search for three ? )).

So : one table and as many subscription types. Consequently, working with this ONE table that you already know.


"SELECT `user_id` , `username` FROM `signup`, signup1` WHERE username = '$user_username' AND password = SHA('$user_password')" . - never insert user input directly into a query! This is another mortal sin. The placeholders, PDO - give hope ))
Already thought about this option and he can't write the code to do this. The idea of two tables seemed easier. But if you know how to write, share. I understand you need the table to insert other fields user_id1 username1 password1. Then how to check and how to do the task for me is impossible. - damion.Casper54 commented on March 19th 20 at 09:29
@damion.Casper54, Basil all have described - one table, in one column, responsible for user type. To check the type of user, just checking this value. - Kavon.Larkin commented on March 19th 20 at 09:32
you just need to add a field subscription_type.

then do a query against the user table for the password and login. If the query returns the user, see what type of subscription he sent to the desired page (it would be good to keep this type of session and on each request check to see where the user to put and where not.)

I think you need to find an article on the implementation of registration and login, user's login password.
For example , it is possible to look for starters

PS and better look for example on PDO. It is more modern and safe solution. - Kendra.Spinka commented on March 19th 20 at 09:35
@beginner03, I obviously don't use neither. - Kendra.Spinka commented on March 19th 20 at 09:38
@beginner03, Yes, frameworks are the same )) - Kendra.Spinka commented on March 19th 20 at 09:41

Find more questions by tags Knowledge basePHP