Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Problem is only when Apps Request for permission window appears after user allow the application then $_POST['mystatus'] dnt get value and status is updated as NULL on user id.</p> </blockquote> <p><em>Of course</em> there is no value in $_POST['mystatus'] – because the request that send this parameter is a thing of the past already.</p> <p>Here’s what happens:</p> <ul> <li><p>User posts the form contents to your server. In handling that request <em>and that request only</em>, you have access to this data via $_POST.</p></li> <li><p>But the user is not logged in, so you <em>redirect</em> them to the Auth dialog. That means, your scripts execution <em>ends</em> at this point, and the client (browser) makes another request. This request goes to Facebook, and after successful login, the client is redirected again, back to your app’s server.</p></li> <li><p>This last redirect results in another request (and a GET request, to be exact) to your server by the client. It has nothing to do whatsoever with the first POST request your app received – there is absolutely no connection between them. And so of course, you do not have access to the data that was POSTed to your app long time ago in a completely different request.</p></li> </ul> <hr> <p>These are <em>basics</em> of using HTTP, that you should make yourself familiar with if you want to develop web applications. <strong>HTTP is a “stateless” protocol</strong> – please look up what that actually means!</p> <hr> <p>Now that we’ve covered these basics, for the solution:</p> <p>One way of introducing a way of “recognizing” requests by the same client that have some logical connection to each other in the stateless protocol HTTP is using a mechanism called <strong>“Sessions”</strong>. (I don’t want to go into theoretical details here – but PHP has an easy to use session mechanism; if you are not familiar with that, please read up on that as well.)</p> <p>So, what you can do, is put the data you received via POST in the first request into the session, and store it there for later retrieval.</p> <p>Then, if the user is not already logged in, you redirect them to the Auth dialog. And once the user “comes back” from there, you check your session and see, <em>“ah, there’s still some data that I’ve received some time earlier with another request, that hasn’t been processed yet”</em> – and then you do exactly that, process it: Retrieve the status message from the session, post it to Facebook, and delete it from the session afterwards (so you won’t process it again on next page load).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload