I have quite a bit of experience in ASP and have just started on PHP.
I have a script that will take a long time to process, let me call it form2.php
Now i post from form1.php to form2.php.
On form1.php I ask the user to enter his email address and tell him that once the process is complete he will be mailed
Now what i need is that when i post from form1.php to form2.php, the browser should show a message that says "processing.. mail will be sent to your address" and let the processing work in the background. I will use ignore_user_abort for this
In the background the script must do what its supposed to do
In form2.php,I have put the message which says "mail will be sent once the process is complete" as plain html on top of the page.
Below that i have put the php code which is the long process. I have used flush(), but it doesnt show the html part till the whole script is finished.
Any idea how to accomplish this?
I dont need multithreading in the true sense.
All i need is to be a able to make a asynchronous call to a say script2.php from script1.php.
Script1.php posts to itself, calls script2.php asynchronously and shows the user a message that says "ill mail you when im done"
Currently the user is left hanging till the process by script2.php is completed and only then the mail is sent which defeats the purpose.
Would posting to script2.php using sockets be a solution?