select * from
(
select 1 as `type`, `username`, `password` from student
union
select 2 as `type`, `username`, `password` from teacher
union
select 3 as `type`, `username`, `password` from admin
) as tmp
where `username` = 'abc' and `password` = 'abc'
แค่นี้น่าจะได้แล้วว่ามี username password ที่กรอกไหม จากนั้น fetch data ออกมาจะได้ type
จากการเดา user กับ password เก็บอยู่ใน table p_tbl_users table เดียว
Date :
2010-02-02 00:19:00
By :
ผ่านมา
No. 13
Guest
เดาต่อ
$strsql = " select 'student' as user_type,authority from p_tbl_users inner join tb_student on p_tbl_user.std_id = tb_student.std_id where user_id='".querysql($_POST['name_login'])."' and user_pwd='".querysql($_POST['pass_login'])."'
union
select 'teach' as user_type,authority from p_tbl_users inner join tb_teach on p_tbl_users.teach_name = tb_teach.teach_name where user_id='".querysql($_POST['name_login'])."' and user_pwd='".querysql($_POST['pass_login'])."'";