0

Good day, as the title says, how can I do that? What I'm trying to do is that on page 1, I looped all data with each having a button that has value of their specific id, then that button redirects to a common page 2, then I use that id on page 2 to display their whole data, but the problem is that when I refresh, the dialog appears.

I tried using session, but the problem is that when multiple tabs are accessing it.

I haven't really tried PRG, but on my understanding, it is used to send changes to the server using another page, then redirect to the previous page, preventing the dialog when refreshing. I thought of using it, but I don't know how to send the fetched data from page 1.5 to page 2

I'd be really grateful for a solution to this, or if someone can link me to similar problems. Maybe this is a duplicate question, but I just can't find the term for my problem. Cheers!!

1 Answers1

0

If you control both pages, change the redirect mechanism on page 1 to GET by simply redirecting to a URL with a parameter appended to the address: target.php?id=42.

If you control only page 2, you may convert a POST request with an id to a GET request:

if (isset($_POST['id']))
{
    header('Location: target.php?id=' . $_POST['id']);
    exit;
}

More on GET vs POST here, as well as a couple of other answers.

Community
  • 1
  • 1
Yury Fedorov
  • 14,508
  • 6
  • 50
  • 66
  • I have already thought of using GET instead, is it ok to let the user see the ID? that's my concern,that's why I didn't use it –  Oct 17 '16 at 09:52
  • It depends. In your case I guess it is OK to use get. The link in my answer leads to a discussion on get vs post, check it out. – Yury Fedorov Oct 17 '16 at 12:05
  • I guess I'll go with this approach, thank you for the answer, Cheers!! –  Oct 18 '16 at 01:44