Solved

form to email - pause and redirecting after submission

Posted on 2004-04-20
2
844 Views
Last Modified: 2012-05-07
Hi, I've got an html form which basically sends output to a php script, which emails it  like so :
<form action="send.php" method="post" name="quoteform" id="quoteform">

and this is send.php
<?php
$to = "me@abc.com"; // E-mail address to send mail to.
$subject = "Online Quote Form"; //Subject of the e-mail
$message = "Quote request received:
Name: $ctcName
Tel: $ctcTel
E-mail address: $ctcEmail;

mail($to, $subject, $message, "From: $name <$ctcEmail>\nX-Mailer: PHP/" . phpversion());
mail($cc, $subject, $message, "From: $name <$ctcEmail>\nX-Mailer: PHP/" . phpversion());
echo "redirecting..please wait";
sleep(8);    //slight pause to display message above
header("Location: http://www.google.com/"); /* Redirect browser */
exit;
?>

Well, I get the following error:
Warning: Cannot modify header information - headers already sent by (output started at /home/mydomain/public_html/send.php:2) in /home/mydomain/public_html/send.php on line 30

I figured that prob is because  header can only be used as the first statement in a script yes? So is there a way I can redirect after displaying a message like 'thank you' for a few seconds?

Thanks...
0
Comment
Question by:skylabel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
venkateshwarr earned 500 total points
ID: 10874975
You can attach this script to your script

<HTML>
<HEAD>
<script>  
function redirect()
{
 window.location.href='http://www.google.com';
}
</script>
</HEAD>

<BODY onload="setTimeout('redirect()', 5000)">
Thank you..
Redirecting in 5 secs..
</BODY>
</HTML>
0
 
LVL 12

Expert Comment

by:venkateshwarr
ID: 10874988
or

<HTML>
<HEAD>
<META HTTP-EQUIV="Refresh" CONTENT="5; URL=http://www.google.com">
</HEAD>
<BODY>
Redirecting in 5 secs..
</BODY>
</HTML>
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question