Solved

form to email - pause and redirecting after submission

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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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 …

758 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

19 Experts available now in Live!

Get 1:1 Help Now