简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM