0) { $result = mysql_query(" SELECT * FROM Courses WHERE teacher = '$_SESSION[user_id]' && course_id = '$course_id' "); } else { $result = mysql_query(" SELECT * FROM Courses_Users WHERE user_id = '$_SESSION[user_id]' && course_id = '$course_id' "); } // if user is neither teacher or student of this course: flag error if(mysql_num_rows($result) == 0) { header("Location: error2.php"); exit(); } ?>