So basically after a user submits a form I want to create a php background process that checks some stuff with the data they submitted, even if they leave I still want it to be checking but the problem is that I can't get anything to work, I've already looked at all questions related to this on the site and could not find a solution. I did find this code here
exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, "output.txt", "pid.txt"));
but the problem with that is that it only outputs the last thing and it adds some junk in there to.
Output:
sh: line 1: *****: command not found