Okay so I made a form on a website so that someone can write down their information and submit a message to an email. It then redirects them back to the homepage of the site, the problem I'm having is that it doesn't show when the message has sent, it just takes me back to the homepage automatically. How can I put a small delay so that it will show that the email was sent? Maybe I need to make it pop in a message box instead? It's been a while since I've worked with php so I'm a bit rusty.
<?php
ob_start();
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$from = 'From: Subject';
$to = 'myemailhere@example.com';
$subject = 'Subject';
$body = "From: $name\n E-Mail: $email\n Phone: $phone\n Message:\n $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Your message has been sent!</p>';
} else {
echo '<p>Something went wrong, go back and try again!</p>';
}
}
$url = 'http://example.com';
while(ob_get_status())
{
ob_end_clean();
}
header("Location: $url");
?>
Also I replaced a few things with generic information, sorry guys you're not getting my email.