Perform a PHP loop every X seconds -


i have user type in how want message sent defined $time variable

this loop code have right now

$time = $_post["time"];  ($x = 0; $x < $amount; $x++) {     mail($completenum, $subject, $message, $headers);     sleep($time);  } 

the issue code messages never sent through, believe it's because sleep function halts script. ideas?

php isn't correct language this, want try javascript or similar.

php designed let dynamically build page when loaded. putting sleep in there, you're delaying load time of page, , server and/or browser going time out - pages aren't expected take excessively long times load, , indicates error. different browsers going different things, , you'd need modify timeout settings on if delay long one.

a scripting language keeps running in browser going able kick off periodically want, , update page - want code keeps executing after page loaded.

alternately, if want php only, php code store request in database, , have 'processing' page hit periodically cron job or similar in background, sends out emails per time delay. there ways achieve want php only, depending on actual end result you're after, putting sleep() loading of page unlikely reliable solution.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -