php – How to set variable to specific field when querying

Question

I am trying to validate an input box against a field in a database. My question is, how does one check a single input equal to any field in a column? I am able to connect to my query, but am unable to perform the validation. Am I missing something?

Here is my code:

add_action('woocommerce_checkout_process', 'username_auth');

function username_auth() {
        
global $wpdb;

    // INPUT FIELD
$username = $_POST['custom_field_username'];

$user_login_sql = $wpdb->get_results("SELECT username, FROM registration_info WHERE username");

    if(isset($username) && $username !== $user_login_sql) {
        wc_add_notice(('Incorrect username123'), 'error');
    } 
    
}

0
John Lyons 2 months 2022-09-30T15:50:08-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse