Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:10:46+00:00 2026-06-08T19:10:46+00:00

I have php page where I used a form to submit messaage. It submits

  • 0

I have php page where I used a form to submit messaage. It submits to itself :

action="<? php echo $_SERVER['PHP_SELF'];?>"

Then it sends email, and I have a javascript function that uses jnotify, to alert whether message is sent successfully or not. This function checks if php variable $sent==’yes’ then notify about sucessful message else notify about error.

The problem is that when user sends message and goes to another page and comes back by using browsers back button, it is displaying notification. I want it to show notification once only and forget about notification when browsers back or refresh used.

What is the best solution for it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:10:49+00:00Added an answer on June 8, 2026 at 7:10 pm

    Try something like this:

    <?php
    
    session_start();
    
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
        if (form_is_valid()) {
            $_SESSION['form_success'] = true;
        } else {
            $_SESSION['form_success'] = false;
        }
        header('Location: ' . $_SERVER['PHP_SELF'];
        exit;
    } else if (isset($_SESSION['form_success'])) {
        if ($_SESSION['form_success'])) {
            // insert success javascript
        } else {
            // insert failure javascript
        }
        unset($_SESSION['form_success']);
    }
    
    // display_form
    

    This should make it so they only see the success/failure message once, and if they use the back button at a later time, they will not receive a warning about re-submitting post data, and they also won’t see a success/failure message twice. The only time that javascript should show is if they just submitted the form in the last request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have used this tutorial http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/ to create php - jquery - ajax
I made a script to post comments on a page. I have used PHP
Is there anyway of detecting a duplicate form submit with PHP? I have a
I have a page, test.php, with the following code: <html> <body> <form> <script type=text/javascript>
I have a PHP page where i want to open a file on a
I have a PHP page that loads external content using other PHP files. I'm
i have a php page that redirects (if successful) to another php page like
I have this PHP page where the user can select and un-select items. The
I have a php page with a dropdown list that is populated by a
I have a php page and i have some javascript code to have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.