i have tried to make a login in Phonegap and tried to connect it to my DB
it works when i use 'postman'
it alerts the correct email + password combi it alerts an empty string it logs and empty object
what am i doing wrong ? as im getting a reponse from the server but empty, it seems like my parameters are not getting transfered correctly
$("#submit").click(function() {
var email = $("#username").val();
var password = $("#password").val();
if (email == '' || password == '') {
} else {
$.ajax({
type: 'GET',
url: 'http://xxxxx.php',
crossDomain: true,
data: {
email: 'email',
password: 'password'
},
dataType: 'json',
success: function(JSONObject) {
alert(email + password);
alert(JSON.stringify(JSONObject));
console.log(JSONObject);
},
error: function() {
//console.error("error");
alert('Not working!');
}
});
}
});
login.php
<?php
//Importing Database Script
require_once('dbConnect.php');
//GETS
$email=$_GET['email'];
$pass=$_GET['password'];
//Creating sql query
$sql = "SELECT * FROM `customerdata` WHERE customerNo = '$email' AND customerName = '$pass'";
//getting results
mysqli_set_charset($con,'utf8');
$r = mysqli_query($con,$sql);
//creating a blank array
$result = array();
//looping through all the records fetched
while($row = mysqli_fetch_array($r)){
//Pushing information in the blank array created ID, deviceID, terminalnumber, qrcode, cloakroomsection, cloakroomnumber, delivered, collected
array_push($result,array(
"customerName"=>$row['customerName'],
"customerNo"=>$row['customerNo']
));
}
//$finalresult= array();
//$finalresult['1'] = $result;
//Displaying the array in json format
echo json_encode($result);
//echo json_encode($encoded_rows);
mysqli_close($con);
?>