Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand you correctly, your problem is that the action, and the displaying of the confirmation take place on different pages.</p> <p>One approach to do this is to store the message that is to be displayed on the next page in the user's session:</p> <pre><code>// insert.php $_SESSION["user_message"] = "You were awarded +2 points."; </code></pre> <p>and output it on the following page:</p> <pre><code>// thankyou.php echo $_SESSION["user_message"]; // Or show the box, or whatever $_SESSION["user_message"] = null; // Clean up </code></pre> <p>the potential downside to this is that if the user has two or more pages/tabs of your site open, and navigates a lot across them, the message may appear in the wrong context. For example, if I click "save" in tab A, and refresh tab B, it could happen that the message intended for tab A is displayed in tab B. </p> <p>You could help that by adding a randomly generated key to the message's variable name, and passing that key on to the page you want to display the message on:</p> <pre><code>// insert.php $key = "123456"; // Insert random generation method here, e.g. using rand() $_SESSION["user_message_$key"] = "You were awarded +2 points."; header ("Location: thankyou.php?message=$key"); // Pass the key to the next page // thankyou.php $key = $_GET["message"]; // No sanitation necessary here AFAICS echo $_SESSION["user_message_$key"]; // Or show the box, or whatever $_SESSION["user_message_$key"] = null; // Clean up </code></pre> <p>This is very elegant because </p> <ul> <li><p>the message you want to display remains in your internal session store, and at no point is passed on in the browser, reducing the risk of security holes and such. </p></li> <li><p>by unsetting the session variable, you make sure the message is shown only once, even if the user reloads the page. </p></li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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