At Joomla !, you never access any of the superglobals. In addition, you should always distinguish between incoming and outgoing data. So, to get the input value from the query, use
$password = $jinput->get('pwd', '', 'STRING');
( JInput is the right choice; JRequest deprecated and will be removed in the future). You now have net worth for the job. He is ready to work with PHP.
The next is to use the value in the SQL query (outbound), you need to avoid it.
$query->where("username = " . $db->quote($loginUsername) . " AND password = " . $db->quote($loginPassword) . " AND state > -1");
Unlike $db->escape() , $db->quote() adds the quotes needed by the underlying database engine.
Why not handle it in one step?
Well, at some point you may need a different type of output, for example. in the view (even if the password is not suitable for this example, I use it for consistency):
echo $this->escape($password);
Therefore, you should always avoid as close an opportunity as possible, where necessary. For incoming data, this is immediately after extraction, for outgoing data immediately before sending / printing.
nibra source share