dongyidao1461 2012-05-30 20:01
浏览 20

如何防止更新其他数据库记录?

I have table which read all the database from phpMyAdmin and dysplay it by php code. - I am also can update each cell on the table, example by using the the row of the table which equal to ID in my database and colume which equal to (first name,last name,password)everting work ok. so if the user click on the one of cell inside the table the jquery send by ajax the parameter ID and the colume one of the field(first name,last name,password). what is my problem? my problem is how can I prevent from haker or smart user which can see the jquery code and he will understanding that he can change the value of any ID or password parmeters and ajax can update database not the correct ID? supose I display to user table with 10 lines which have ID from 11-20 the user will change the ID parameter ID equal to 500 it can hapend.

$(document).ready(function()
{
    var COLUME, VAL,ROW,STATUS,DATASTRING;

    $('td').click(function() {
        COLUME = $(this).attr('class');   
      });
//****************
    $('tr').click(function() {
        ROW = $(this).attr('id');
        $('#display_Colume_Raw').html(COLUME+ROW);
        //$('#display').html(COLUME+ROW);
        $('#span' + COLUME + ROW).hide();
        $('#input'+ COLUME + ROW ).show();
      STATUS = $("#input" + COLUME + ROW).val();
    });
  //******************** 
    $(".edittd").mouseup(function() {
        return false;
    });
  //*************
    $(document).mouseup(function() {
        $('#span' + COLUME + ROW).show();
        $('#input'+ COLUME + ROW ).hide();
        VAL = $("#input" + COLUME + ROW).val();
        $("#span" + COLUME + ROW).html(VAL);
          if(STATUS != VAL){
          $('#statuS').removeClass('statuSnoChange')
            .addClass('statuSChange');
             $('#statuS').html('THERE IS CHANGE');
             DATASTRING=$('#display_Colume_Raw').html()+','+VAL;
            //******ajax code
                 //dataString = $.trim(this.value);
                      $.ajax({
                        type: "POST",
                         dataType: 'html',
                         url: "./public/php/ajax.php",
                         data: 'DATASTRING=' + DATASTRING, //{"dataString": dataString}
                             cache: false,
                             success: function(data)
                             {
                                //alert(data);
                                $("#statuS").html(data);
                                }
                             });
                      //******end ajax
                 }
                 else
                 {
                 //alert(DATASTRING+'status not true');
                 }

        });       
    });

enter image description here

  • 写回答

2条回答 默认 最新

  • drmqzb5063 2012-05-30 20:07
    关注

    There is no point showing front-end code as this is something you implement on the back end.

    In the method that gets called via AJAX, simply check whether the user has permissions to perform the requested action or not. You can either have a separate check at the top of the method and return if the user it not allowed, or you can build it in to the delete query itself, e.g., by adding a WHERE clause making sure those IDs are ones that user is allowed to delete.

    评论

报告相同问题?

悬赏问题

  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据