Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php login using 2 database tables

Tags:

php

mysql

I'm trying to make a login script using 2 database tables (authors and editors). I'll post an example of them: Table 1: authors

|id|username|password|
| 1|  user  |  xyz   |

Table 2: editors

|id|username|password|
| 1| editor |  abcd  |

I want to make a single login using these 2 tables. I tried to use:

SELECT * FROM authors, editors WHERE username='mysql_real_escape_string($username)' AND password='mysql_real_escape_string($password)'

but it didn't work. Is there another way that should work for me? Thank you.

like image 926
user3413016 Avatar asked Aug 01 '26 12:08

user3413016


1 Answers

You shouldn't do it this way, use one table with in it a roleid or something like it. This will eventually break.

If you really want to do it, no matter what, I would suggest doing a select on the author's table first. No result? Query the editors table.

But as I said, don't do it.

like image 74
Chilion Avatar answered Aug 04 '26 03:08

Chilion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!