No doubt there is a very quick and easy solution for this but I can’t seem to get my head around it. How would I go about returning the variable $errMsg from the function below? So I can display it on the page where the function is being called.
function login(){
global $wpdb;
if( isset($_POST['login_btn'] )){
if (empty($_POST['login_username'] || empty($_POST['login_password']))) {
$errMsg = 'Invalid Username or Password';
return $errMsg;
}else {
$login_username = $_POST['login_username'];
$login_password = $_POST['login_password'];
$u = $login_username;
$p = $login_password;
$query = $wpdb -> prepare("SELECT * FROM 'wp_members' WHERE 'username' = %u AND 'password' = %p", $u, $p );
// If there is a matching username and password then redirected to login
if ($query == true) {
$_SESSION['login_username'] = $login_username;
header('Location: /flourishWP/wp-content/themes/blankslate/includes/admin.php');
}
}
}
}