Get values and parameters from url with jquery in cordova with example
Paste in Function.php file
function check_login(){
if(function_exists('date_default_timezone_set')) {
date_default_timezone_set("Asia/Kolkata");
}
// then use the date functions, not the other way around
$date = date("d/m/Y");
$date1 = date("H:i a");
$phone = $_POST['phone'];
$password = $_POST['pass'];
global $wpdb;
$table_name = $wpdb->prefix ."customer";
$result = $wpdb->get_results ( "SELECT * FROM $table_name WHERE phone='$phone' AND password='$password'" );
$count_users = count($result);
foreach($result as $print_result){
}
if($count_users>0){
//echo '<script>window.location.href="dashboard.html";</script>';
echo $print_result->ID;
}
else{
echo 'null';
}
die();
}
add_action('wp_ajax_nopriv_check_login','check_login');
add_action('wp_ajax_check_login','check_login');
Paste in Login.html file
$('.login').click(function(e) {
e.preventDefault();
var phone = $(".l_phone").val();
var pass = $(".l_password").val();
var ajax = "http://wpcodekit.com/wp-admin/admin-ajax.php";
if(phone==''){
alert('All field are required');
return false;
}
if(pass==''){
alert('All field are required');
return false;
}
//alert(pass);
var data = {
'action' : "check_login",
'phone' :phone,
'pass' : pass
}
$.post(ajax,data,function(response){
var user_id = response;
window.location.href="dashboard.html?ID="+user_id+"";
//alert(user_id);
console.log(user_id);
});
});
Paste in dashboard.html file
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var first = getUrlVars()["ID"];
alert(first);
Comments
Post a Comment