I am currently learning jQuery and php.
So I have this php file that gets called with a jQuery function (there is another call somewhere else in the script where a=chkPw):
$.get("checkName.php?a=chkUser&user=" + rqUser, function(data) { ... });
My problem is that the php script doesn't seem to get in the if(isset($_GET)) { } block. I have debugged the value that it returns (1), so I don't understand what's wrong! I have also debugged the value for $_GET['a'] and it is indeed 'chkUser'.
Any help would be greatly appreciated.
<?php
$users = array('bill' => 'ore', 'ted' => 'wood');
if (isset($_GET)) {
if ($_GET['a'] == 'chkUser') {
if (!array_key_exists($_GET['user'], $users)) {
echo 'okay';
} else {
echo 'denied';
}
} elseif ($_GET['a'] == 'checkPw') {
$user = $_GET['user'];
$pw = $_GET['pw'];
$i = 0;
// get username id
foreach (array_keys($users) as $value) {
if ($value == $user) {
$user = $users[i];
}
i++;
}
// match pw
if ($pw == $user) {
echo 'okay';
} else {
echo 'denied'
}
}
}
?>
$.get('checkName.php',{'a':'chkUser','user':rqUser}, function ...