Several PHP processes

I have a page where users enter their email address, click "Submit", and the web server will send them an email application ~ 10 MB in size. Right now, “Sending ...” is displayed on my page, and the user waits about 20 seconds on this page.

Instead, I want him to say: “Your application will be emailed in a few minutes,” sending this process to another location and allowing the user to continue browsing without opening a new tab.

I really need someone to point me in the right direction, because I don’t even know what to do with Google at the moment.

+4
source share
2 answers

You can call another php file that will handle sending emails and be sure to include this call:

ignore_user_abort(true); 

What this does allows you to complete the php process, even though the browser quits. This way you can initiate the process via ajax, and then go to another page where your attachment was sent.

For more information:

http://www.php.net/manual/en/function.ignore-user-abort.php

+2
source

I recommend checking out this question that I posted some time ago.

How to run a PHP script in the background after submitting a form?

The answer explains how you can run a PHP script in the background after submitting the form. This, of course, is just one way to achieve this. Another would be to create an address list and configure cron to run the script over a time interval. Both can do the same thing, it depends only on how you want to solve the problem and what you can do on your server.

0
source

Source: https://habr.com/ru/post/1381360/


All Articles