A php code sent a query to the database say credentials from login page for verifying and something was returned say TRUE OR FALSE as status. Now my question is, if I do not know the code of the developer who wrote the login form, does there exist any way to find out what query is made to the database OR what has been returned by the database? Since I'm unaware of the developer's code which means I'll need a parallel script working in parallel with the login form. Can I also do that? The reason why I asked this question is I just want to sanitize the output data from the database as being a little paranoid, I can't trust the data coming from the database. Some XSS issue, nothing more.

does there exist any way to find out what query is made to the database

It is logged in the mysql query log, IF it has been enabled.