Run a PHP postback request on a page only once?
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?
<input type="submit" value="submit" name="submit_button" />
<?php
if(isset($_POST['submit_button']))
{
// only execute if postback
}
?>
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.
精彩评论