• 0

PHP script executing twice for no apparent reason


Question

I have a PHP script that runs twice for a certain (very important) user. I can not get it to run twice, even using the same browser. Unfortunately, I can't link to it here.

The script is part of a newsletter system I've been writing. In this particular section (actually creating and sending the letter) there are 3 pages - the first is where the administrator enters the subject, the newsletter and the category or categories of subscribers that it is to sent to. They then click on send and they got a confirmation page. This shows how many members are in the categories they selected and an overview of the letter. If they're happy, they then click on Confirm and the final script loops, going through the database and gets the details for each subscriber (name, email address, etc), personalizes it for that subscriber and sends off the email. The problem is that the final script will execute twice for a particular administrator, sending everyone two emails.

I've done some sniffing at log files and found that it is executed twice, rather than some bug making a large part of my script get looped twice. Interestingly, the first execution has the HTTP_REFERER set correctly to the confirmation page. The second call has no HTTP_REFERER set. The time difference between the 2 scripts being run is 0 seconds (all the logs are precise to just 1 second). I'm pretty sure the admin isn't calling it twice. I put in javascript to disable the submit button after it's clicked much like this board has for the reply button (in fact, very much like what this board has :shifty: ). Also, the HTTP_REFERER isn't set for the second execution when it should be. The fact that it is set for the first one shows that it is indeed working (I know thisn't 100% reliable). The newsletter details are passed on both executions (via POST).

I've helped the issue somewhat but it's treating symptoms, not the cause. The submit disabler failed completely but more successful is the anti-dup system I implemented. Each sent letter is saved for future viewing along with the time it was send - before running the main read member info/send email loop, I checked the saved messages for one with the same subject, body and any of the same subscriber categories that have been sent in the last 30 mins and quit with an error message if any are found. It works, but I'd like to fix it properly.

2 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I don't know, I haven't checked what changed in previous sockets. I agree that the 1156-1155-1151 succession was suspicious, with a reduction in pin count every time. Intel could do a better job of pre-allocating pins for future use. Another hypothesis is that the internal layout of their CPUs change, like the I/O is moved from one place to another on the chip, and they need to reorganize pins rather than having circuitry go into spaghetti mode to remain compatible. I agree that if AMD is able to maintain compatibility, Intel should be able to do the same, at least by reserving pins for future use and then using those pins when a need for them arises. However, I wouldn't say that AMD's products are entirely better. Intel's I/O now slightly edges out thanks to having double the bandwidth to the chipset and dedicated Thunderbolt lanes to the CPU. It seems that they could widen their lead with the next platform. NVMe SSDs have increased the need for PCIe lanes significantly, and AM5 has been pretty underwhelming in that regard, especially because the chipset connection is so narrow and gets saturated with just 1 gen 4 SSD, leaving the other chipset connectivity (Ethernet, Wi-Fi, audio, etc) to hope for any remaining bandwidth. Otherwise motherboard manufacturers could also make more x2 M.2 slots, those would be fast enough at gen 5 speeds and possibly at gen 4 speeds too.
    • Exactly, the E-cores actually give you good performance for what they offer, it's no surprise that Intel is doubling down on more E-cores instead of more P-cores. The LP-cores are good for when you're system is just sitting there idle and waiting to be used. Every core has it's place tbh, it's just up to Intel to and MS to work to get the scheduler right.
  • Recent Achievements

    • Week One Done
      korostelev earned a badge
      Week One Done
    • Week One Done
      rozermack875 earned a badge
      Week One Done
    • Week One Done
      oneworldtechnologies earned a badge
      Week One Done
    • Veteran
      matthiew went up a rank
      Veteran
    • Enthusiast
      Motoman26 went up a rank
      Enthusiast
  • Popular Contributors

    1. 1
      +primortal
      675
    2. 2
      ATLien_0
      264
    3. 3
      Michael Scrip
      184
    4. 4
      +FloatingFatMan
      177
    5. 5
      Steven P.
      140
  • Tell a friend

    Love Neowin? Tell a friend!