Solved

form to email - pause and redirecting after submission

Posted on 2004-04-20
2
845 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 …

734 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