The below query is always returning an empty array i have checked that the $_POST is working but i am unsure what is going on?
$database = new wpdb(QLBBackendUser, QLBBackendPass, QLBBackendDB, DB_HOST);
if (isset($_POST['register-user'])):
$user = $database->get_results('SELECT * FROM users WHERE email='.$_POST["user_email"]);
var_dump($user);
endif;
Please note this is for WordPress using WPDB Class.
You should never call the
wpdb
class directly…If you must, use the global$wpdb
object instead. In addition, make sure theuser_email
has beenPOST
ed (I’m not sure why you’re checking forregister-user
being set and notuser_email
). Also, it’s highly unlikely that the table you should be querying is calledusers
(without a prefix). It’s likelywp_users
if you’re using the default prefix.Finally, there is a handy function that already does what you’re trying to re-implement, called
get_user_by
:I recommend using the above, instead of trying to re-invent the wheel.