Running PHP as a Background Task
Results 1 to 8 of 8

Thread: Running PHP as a Background Task

  1. #1
    Junior Member
    Join Date
    May 2008
    Posts
    18

    Running PHP as a Background Task

    Let me start by saying I'm not sure if this is a PHP or Javascript problem. Here's the situation:

    I have an HTML page that displays a Modal Window when it loads. The window is a small form, which is optional. If the viewer decides to fill it out, when they click the Submit button the form is validated and, if all is okay, the window is removed and the form data sent (via action=) to a PHP routine for further processing.

    I would like the viewer not to be aware of the PHP routine running (there are no messages sent to the viewer from this routine).

    I have tried ending the routine with
    Code:
    echo "<script>history.back();</script>";
    and that returns the viewer to the HTML page without the Modal window being redisplayed in every browser that I've tried, except for IE, which redisplays the HTML page (with the Modal Window active). So, I have 2 questions:

    1) Is it possible to have the PHP routine run in the background (so the viewer never leaves the HTML page?

    2) If not, is there a way to have IE just return to the HTML page without reloading it?

    Thanks in advance for your help.

  2. #2
    Pna lbh ernq guvf¿
    Join Date
    Jul 2004
    Location
    Kansas City area
    Posts
    19,429
    Sounds like what you're wanting is client-side behavior - moving to ClientSide Technologies forum.

    It sounds like what you want to do is submit a form without causing the user to actually navigate away from the current page. If so, I'd suggest you take a look at an AJAX approach which uses Javascript to make a POST (or GET, if you prefer) request in the "background" so to speak, meaning the location in the browser window never changes despite the communication with your server after the user submits the form.

  3. #3
    Junior Member
    Join Date
    May 2008
    Posts
    18
    bradgrafelman.

    Thank you for your response. I've actually looked at AJAX, but I really don't have time to learn a totally new language (even if it is Javascript base). Is that my only option? Is there an AJAX forum where someone would be willing to help me with the code?

    Again, thanks in advance for your help.

  4. #4
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,885
    Well, it's not a totally new language, just using an object available in an existing language (unless you're talking about jQuery, which in this instance is again not so much a new language as cross-platform wrappers to simplify common uses of the Ajax idiom).
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  5. #5
    Junior Member
    Join Date
    May 2008
    Posts
    18
    Weedpacket.

    I appreciate your reply, although I'm not sure I understand what you said. Is there a forum where someone could assist me in setting up the AJAX code?

  6. #6
    Senior Member
    Join Date
    Oct 2005
    Location
    Chicago, IL
    Posts
    428
    Lynda is a pretty good tutor..

    Otherwise, google has a lot of examples to select from and this place here is good if you get stuck along the way. Happy Learning!

    J
    Bob Lob Law

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    18
    Download phpAdsNew and look at the fakecron.php file. It "fakes" cron by running a background process triggered by a 1x1 pixel image placed on the page you want to trigger the background operation.

  8. #8
    Settled 4 red convertible dalecosp's Avatar
    Join Date
    Jul 2002
    Location
    Accelerating Windows at 9.81 m/s....
    Posts
    7,715
    Quote Originally Posted by jimweinberg View Post
    Weedpacket.

    I appreciate your reply, although I'm not sure I understand what you said. Is there a forum where someone could assist me in setting up the AJAX code?
    He said something like
    Quote Originally Posted by The Weedpacket Translator
    AJAX isn't a new language, it's just something you can do with Javascript, unless you are specifically talking about using AJAX from a Javascript framework (he mentions jQuery {other Javascript frameworks are MooTools, YUI, Scriptaculous, many others}) --- which isn't a language, but a framework that exists to simplify common Javascript use cases (like AJAX).
    AJAX stands for "Asynchronous Javascript And XML" ... and I think we all better get used to the idea. Maybe not this week, or this month, but we're going to be less and less relevant as web programmers if we can't perform these sort of tasks.

    Granted, not everyone is a "web programmer" ...
    /!!\ mysql_ is deprecated --- don't use it! Tell your hosting company you will switch if they don't upgrade! /!!!\ ereg() is deprecated --- don't use it!

    dalecosp "God doesn't play dice." --- Einstein "Perl is hardly a paragon of beautiful syntax." --- Weedpacket

    Getting Help at All --- Collected Solutions to Common Problems --- Debugging 101 --- Unanswered Posts --- OMBE: Office Machines, Business Equipment

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •