Solved

form to email - pause and redirecting after submission

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

914 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now