php - Update database phone number


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('assets/footer.php'); // create footer

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;


<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>


    url = '/cs382/cookead06/final/final_app';

    if ($('#uid').val() != '-1'){
        $('#sign-in' ).hide();

    $('#p2').on('change', function(){
    $('#p3').on('change', function(){
    $('#p4').on('change', function(){

    // validate user

    $('#updatephone').on('click', function(){
        var f_id = $('#uid').val();
        var phone = $('#newPhone').val();
              type : 'post',
              url : url + '/index.php?action=changephone',
              data : 'indID=' + f_id + '&mobilePhone='+ phone,
              success : function(response){

    $('#signInBtn').on('click', function(){
        var username = $('#username').val();
        var password = $('#passwd').val();
        var data_items = 'username='+username + '&passwd=' + password;
            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();
                  // update the value of 'uid'
                  // display user's name
                } else
                  alert("Invalid user");

enter image description here




Sorry, read wrongly..

I re-read it and I can see that you are printing $result that is = to $stm->execute($values); that is a sql query, if the query executes successfully, it won't show any message, only if you implemented an echo on the function execute..




Surprisingly, the issue was at line:

$sql = 'update members set mobilePhone=:mobilePhone where indID=:indID';

where members was suppose to cs_members(name of table)

People are also looking for solutions to the problem: Opening a Text File using PHP - Fixing the Format


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.