简体   繁体   English

使用不同表中的用户名和密码登录系统,如何选择?

[英]Login system with username and password from different tables, how to select from?

I have searched for quite a while now about the possibility of having two tables (one for username and one for password) but haven't found anything useful. 我已经搜索了很长时间,关于是否有两个表(一个用于用户名,一个用于密码)的可能性,但没有发现任何有用的东西。

I have two tables linked together with Primary Key and Foreign Key. 我有两个表与主键和外键链接在一起。 One containing the username and one containing the password. 一种包含用户名,另一种包含密码。

My current code is only for one table, like this: 我当前的代码仅适用于一张桌子,如下所示:

   $result = mysqli_query($con, "SELECT membersid FROM members
   WHERE user='{$_POST['user']}'
   AND pass='{$_POST['passwd']}'");

Is there anyway I can use like equi joins together with input in my form? 无论如何,我可以像表单连接一样使用Equi Joins吗?

All I got is this: 我所得到的是这样的:

   $result = mysqli_query($con, "SELECT adminuser.userid, adminpass.passid 
   FROM adminuser, adminpass
   WHERE username='{$_POST['user']}'
   AND password='{$_POST['passwd']}'");

I know it's probably completely wrong, and I searched for an answer but haven't found one, that's why I'm turning here for help. 我知道这可能是完全错误的,我搜索了一个答案,但没有找到答案,这就是为什么我在这里寻求帮助。

Is there anyway to solve my problem? 反正有解决我的问题的方法吗?

I am not sure, but here's my 0.02 cents. 我不确定,但这是我的0.02美分。 You are missing this. 你错过了这个。

ON adminuser.userid=adminpass.userid;

在此处输入图片说明

Or maybe, this is more easy to understand. 也许,这更容易理解。

INNER JOIN is used to combine rows from two or more tables, based on a common field between them. INNER JOIN用于基于两个或多个表之间的公共字段来合并它们之间的行。

SELECT adminuser.userid, adminpass.passid
FROM adminuser
INNER JOIN adminpass
ON adminuser.userid=adminpass.userid;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM