Run a PHP postback request on a page only once?

大兔子大兔子 提交于 2019-12-25 04:43:11

问题


I would like to know if there is an equivalent of IsPostBack in PHP. I want to call a function or a method only once, once the user is logged in.

I have a facebook application, in which once the user authorizes the application it should enter his details in the database. This basic stuff should have been done using the post-authorize callback url which facebook pings when the user first authorizes the app.

The issue is that since I am checking whether the user exists or not in index.php, I would not like index.php to run this code repeatedly for the same user when the user goes to the homepage every time.

Is there any PHP code that will run it only once?


回答1:


<input type="submit" value="submit" name="submit_button" />
<?php
if(isset($_POST['submit_button']))
{
    // only execute if postback
}
?>



回答2:


edit 2: I didn't misunderstood after all...

If it only has to run once per login, you could save the state to the session, so you can see if it has to executed or not.



来源:https://stackoverflow.com/questions/2841857/run-a-php-postback-request-on-a-page-only-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!