I am developing a Web Application where a user will signup either through Email or Phone Number.
I have a long code to execute including Validation, Sanitization, Escaping, Session and some DB related tasks etc. After that it decides whether to send email or text message to user for confirmation. Sending an Email or Text Message sometimes takes a little bit time and until that user waits for response from server. Therefore, I thought of sending confirmation through a Thread so, that I can immediately return response to user. P.S. I am new to Threads in PHP.
if(//Validate)
{
//Sanitize & Escape
if(//Everything is good)
{
Thread.start()
{
//Needs to send Email or Text Message for confirmation
//Should I start a Thread here which sends confirmation so that as soon as a thread is started
//a response is sent back to user?
}
//Return response, Confirmation sent (User will not have to wait until confirmation is sent
//because that is being sent through another thread)
}
}
My Concerns are following
1) Should I be using Threads for sending confirmation message? Because otherwise user will have to wait for a response until a message is not completely sent which takes some time.
2) I read about pThreads
at How can one use multi threading in PHP applications but it says that I should not be using pThreads in web server environment
. Is he talking about the scenario I am doing? Should I use pThreads for my app?
3) Is pThread is same as Thread in php?