dongseshu0698 2016-08-21 20:32
浏览 50

阻止用户访问浏览器导航栏中的login.php进程文件

<?php
if(isset($_SESSION['id'])==null){


    header("Location: login.html");
}
?>
<script>
$(function(){
$(document).on("click", ".button", function(e) {
e.preventDefault();
{       
//This will capture all the inputs from the form
var infom = $("#myform").serialize();
        //$("#showresult").addClass('loader');                
        $.ajax({            
            beforeSend: function() { },         
            type: "POST",
            url: "login.php",
            data:infom,          
            success: function(result){      
            //$("#showresult").removeClass('loader');
            $('#showresult').html(result);
            }
        });     
        e.preventDefault(); 
}
}); 
});
</script>

in the login.php file i placed that but it does nothing the user is still able to put in login.php within the browser navigation and still get to it. I want to stop them from doing so. I want that file to only call when i try to login on the login html page. Above is the ajax code used to display error message if any from php. when i combine it with the if post or http reffer, it redirects to a blank page with continuous loading.

  • 写回答

2条回答 默认 最新

  • duanchangnie7996 2016-08-21 20:44
    关注

    you can check with this

    if($_SERVER['HTTP_REFERER']=="complete URL/login.html")
    

    the url must be like http://www.example.com/login.html

    and if you are submitting a form from login you must check $_POST .

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?