N
N
nsmilyk2019-03-31 16:09:44
PHP
nsmilyk, 2019-03-31 16:09:44

Working with two tables in Php DB?

The essence of the question is as follows: there is a site to which people purchase a subscription. There are 2 types of subscription and depending on the choice, users are granted access to certain pages. I solved this problem with the help of 2 tables signup and signup1. Each contains user_id username password fields.
A person buys a subscription and, depending on the purchase, he receives a login and password from the corresponding table. I was able to connect to one table on submit, it looks like this:
But I can’t imagine how to connect the second table here. That is, it should work like this: if there are no matches in one table, then the handler should check in the second and issue an answer.
Unfortunately, I’m not strong in PHP, I searched on the Internet, they say that in order for this to happen, you need to do this:
But that doesn't work. Ask for advice from knowledgeable people.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
coderisimo, 2019-03-31
@nsmilyk

The title of the question is "Working with two databases Mysql Php?" not correct. You are using one DB but two tables.
In fact, it would be more correct to use ONE table. And add a field in it, something like
subscription_type. Then you don't have to search first in one and then in another table. And if another type of subscription appears, will you create a third table and search for three? )).
So: one table and any number of subscription types. Accordingly, you work with this ONE table, which you already know how to do.
PS
"SELECT `user_id` , `username` FROM `signup`, signup1` WHERE username = '$user_username' AND password = SHA('$user_password')". - never insert data from the user directly into the request! This is another deadly sin. Placeholders, PDO - give hope ))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question