Hi,
I have an mp3 upload script. The first page submit.php has a form action of submiterror.php. On the submiterror.php page it checks to see if the button is pressed.

if (isset($_POST['submit_mp3'])) {	

THen it uploads. I was having problems with getting some double entries so i tested it and found that if I refresh the page it will act as if the button "isset" again. Is there a way around this?

Thanks alot.

    hmm... wouldnt solving this be equivalent to solving the multiple forum post problem?

    You could try out ideas from there.

      So sorry laser,
      I thought doubleposting was putting the same question in two different boards. I thought asking two completely different questions was OK. I've ran into alot of new stuff tonight since I was coding without the ability to test for a few days while my server transferred.
      Believe me, I give an honest search first.

        In this case I'm referring to multiple posts made in the same thread, usually by an impatient user who keeps on clicking 'post'.

        This forum solves the problem by having an intermediate page redirect one back to the page.

        Another way would be to impose a period of no posting immediately after a post is made.
        In your context it means no new uploads by that user allowed until some short time has passed.

          I dont get it?
          Did I post twice in here? I dont see anything?

          Anyhoo, does anybody know of a resolution to the isset issue?

            err, I'm not accusing you of any wrongdoing, I'm pointing out that the methods forum systems use to solve a certain class of problems can apply to your original question.

              laserlights explanation should suffice. For more information, look at http://www.theserverside.com/articles/article.tss?l=RedirectAfterGet. The author of this article calls this method PRG, for POST-REDIRECT-GET.

              His writes this as the mantra:

              Originailly posted by http://www.theserverside.com/articles/article.tss?l=RedirectAfterGet
              Never show pages in response to POST
              Always load pages using GET
              Navigate from POST to GET using REDIRECT

                13 years later

                ozeljko

                I loaded this page and it didn't do it ... 😃 😃 😃

                And thanks for bringing up this important thread from 13 years ago! (Or maybe not).

                At any rate, PHPMagician's post is still worth knowing about; and it may also be worth knowing that some authorities call this strategy "redirect after post" instead of "post redirect get", although it's the same strategy.

                a month later

                dalecosp lol i agree still useful as i was looking for a way to redirect a page after a form submission, everything today is done with plugins and WordPress my php knowledge isnt that great i try to shy away from plugins as much as i can on websites, due to performance issues , so this worked like a charm in writing my own little script. 🙂

                  7 days later

                  It means the script is running everytime you refresh the page, whats triggering the script? you could use something like localstorage.set working with sessions or cookies. TO set a value that will dissalow the script from running if it has already run once. You could use ajax to fetch the post data submit it and prevent default to stop you url from going to where the code is being executed that way it get submitted without a refresh.

                    Write a Reply...