PHP: Detect Page Refresh

前端 未结 9 1456
余生分开走
余生分开走 2020-11-28 13:54

I have a page action.php on which I run an SQL query through the code, so that whenever the page is viewed the query runs like its like counting page vi

9条回答
  •  [愿得一人]
    2020-11-28 14:02

    i have solved the problem ... HURRAHHH with no session & no cookies

    the solution is a combination of PHP : AJAX : JavaScript

    the query that you want to run on Page Load & not on page Refresh run it as via AJAX call lets say my function for doing that is

    function runQUERY()
    {
        xmlhttp=new XMLHttpRequest();
        xmlhttp.open("POST","doIT.php",false);
        xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        xmlhttp.send();
    }
    

    and i can simply check with Javascript that the page is a fresh load or its a refresh by doing the following

    
        
    
    
    
    
    

    and in your doIT.php simple add your PHP code which you were going to put in the normal page

    
    

提交回复
热议问题