Hi guys, how do I created count down timer using php?
The scenario is I want to make a contact form that will send to my email address, after the guests fill out the form I want redirect them to the thanks you page but then I want them to “re-direct” to the home page automatically
The script is
<?php
if(isset($_POST[‘submit’])) {
$to = "myemail@whatever.com";
$subject = “Form”;
$name_field = $_POST[‘name’];
$email_field = $_POST[‘email’];
$url = $_POST[‘url’];
$comments = $_POST[‘comments’];
$body = “From: $name_field
E-Mail: $email_field
URL: $url
Comments:
$comments”;
echo “Thanks for filling out our testimonials”;
mail($to, $subject, $body);
} else {
echo “blarg!”;
}
?>
I also found script using microtime() in php.net but I don’t really understand how it’s work because everytime I refresh it, the time sometimes counting down sometimes counting up
The script is
<?php
/**
- Simple function to replicate PHP 5 behaviour
*/
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = microtime_float();
// Sleep for a while
usleep(1);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds
";
?>