weixin_33711641 2015-05-14 01:07 采纳率: 0%
浏览 25

更新数据库电话号码

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");
              }
         });
     });
});

enter image description here

  • 写回答

2条回答 默认 最新

  • 喵-见缝插针 2015-05-15 14:13
    关注

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

    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流