I want to use WordPress Nonce to verify LogIn form. It not working. My form and Ajax code on Login page And validation on Another page.
HTML
<form id="frmLogin">
<?php wp_nonce_field('test_action', 'submit_post'); ?>
<input type="text" id="InputName" maxlength="150" class="form-control" name="username" required />
<input type="password" id="InputPassword" maxlength="150" class="form-control" name="password" required />
<input type="submit" maxlength="150" class="form-control form-control-lg bg-warning" name="submit" value="Login" />
</form>
// LogIn Validation on Another PHP page
add_action( 'wp_ajax_nopriv_login_data', 'ajax_login_data' );
function ajax_login_data(){
$login_array = [];
wp_parse_str($_POST['login_data'], $login_array );
// Nonce Verify
if(wp_verify_nonce($_REQUEST['test_action'], 'submit_post')){
/// do your work
}else{
/// throw an error
}
}
Please help me to solve this problem.