Currently my running program, when I click the submit new phone number button, my ajax shows a response pop up that is empty.
I don't have any running errors so I don't see the issue.
main index.php file:
case 'updatephone' :
include('assets/header.php'); // create top box
include('assets/sidemenu.php'); // create side menu
// use a template to display result
include('views/displayUpdatePhoneForm.php');
include('assets/footer.php'); // create footer
break;
case 'changephone' :
$sql = 'update members set mobilePhone=:mobilePhone where indID=:indID';
$phone = $_POST['mobilePhone'];
$values = array(':indID'=>$_POST['indID'], ':mobilePhone'=>$phone);
$stm = $db->prepare($sql);
$result = $stm->execute($values);
echo $result;
break;
displayUpdatePhoneForm.php
<h4>Changing Mobile Phone</h4>
<p>Enter new number: <input type='tel' id='newPhone' />
<button type='button' class='btn btn-primary' id='updatephone' >Change Phone</button>
</p>
script.js
$(document).ready(function(){
url = '/cs382/cookead06/final/final_app';
if ($('#uid').val() != '-1'){
$('#sign-in' ).hide();
$('#sign-out').show();
}
$('#p2').on('change', function(){
$('#form2').submit();
});
$('#p3').on('change', function(){
$('#form3').submit();
});
$('#p4').on('change', function(){
$('#form4').submit();
});
// validate user
$('#updatephone').on('click', function(){
var f_id = $('#uid').val();
var phone = $('#newPhone').val();
$.ajax({
type : 'post',
url : url + '/index.php?action=changephone',
data : 'indID=' + f_id + '&mobilePhone='+ phone,
success : function(response){
alert(response);
}
});
});
$('#signInBtn').on('click', function(){
var username = $('#username').val();
var password = $('#passwd').val();
var data_items = 'username='+username + '&passwd=' + password;
$.ajax({
type : 'post', // type: get or post
url : url + '/index.php?action=checklogin', // define server-side script
data : data_items, // define data to be sent
success : function(response){
if (response != -1){
// hide login information
$('#username, #passwd').val('');
$('#login-content, #sign-in').hide();
$('#sign-out').show();
// update the value of 'uid'
$('#uid').val(1);
// display user's name
$('#user-info').text(response);
$('#update-link').removeClass('hidelink').addClass('displaylink');
} else
alert("Invalid user");
}
});
});
});