Login failed in my code after inserting proper login details (i.e username and password), code in php and jquery

后端 未结 2 1312
小鲜肉
小鲜肉 2021-01-28 17:59

I have following code (php and jquery) for Login for Student and Teacher (using same form for both access). In my system the admin can create Student and Teacher. Once created,

2条回答
  •  没有蜡笔的小新
    2021-01-28 18:47

    I think the problem is here;

    if( $count_stu > 0 ) { 
        //$_SESSION['id']=$row_student['student_id'];// mistake
        $_SESSION['id']=$row_stu['student_id'];
        echo 'true';
    }else if( $count_tea > 0 ) { 
        //$_SESSION['id']=$row_teacher['teacher_id'];// mistake
        $_SESSION['id']=$row_tea['teacher_id'];
        echo 'true_teacher';
    }
    else{ 
        echo 'Wrong Username Or Password';
    }
    

    I agree with @Drew Pierce, you should consider using pdo or mysqli.

提交回复
热议问题