weixin_33719619 2015-02-27 16:06 采纳率: 0%
浏览 27

PHP / AJAX发布安全性

On my website I have the following javascript/ajax code that is called when a user submits the logon form.

The login form then checks the information and passes back messages and PASS or ERROR.

On a success message I would then like the ajax to redirect to the php code again to double check for a valid logon before setting up the session, is this necessary? how would i "redirect" from within ajax whilst retaining the $_POST data?

//login form ajax
$("#login-form").submit(
function() {

  $("#FormMessages").removeClass().addClass('alert alert-info').html(
      '<img src="images/loading.gif" /> Validating....').fadeIn(500);

  $.ajax({
    url: $("#login-form").attr('action'),
    dataType: 'json',
    type: 'POST',
    data: {
      username : $('#email').val(),
      password : $('#password').val()
    },

    success: function(data){
      if (data.status == 'PASS') {
        $("#FormMessages").fadeTo(
            100,
            0.1,
            function() 
            {

              $(this).html('Logging In...').removeClass().addClass(
                  'alert alert-success').fadeTo(450, 1,
                  function() {
                    document.location = curUrl;
                  });
            });

      } else {
        $("#FormMessages").fadeTo(
            200,
            0.1,
            function() 
            {                    
                $(this).html('<h4>Error!</h4>')
                    .removeClass().addClass('alert alert-danger')
                    .fadeTo(450, 1);

              $("#FormMessages").append('<ul>');
              $(data.messages).each(function(i,obj) {
                $("#FormMessages").append(''+obj+'');

                });
              $("#FormMessages").append('');                  
            });
      }

    }
  });


  return false;
});

Thanks for reading!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题
    • ¥15 matlab中使用gurobi时报错
    • ¥15 这个主板怎么能扩出一两个sata口
    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么