Click to See Complete Forum and Search --> : Self closing thank you window


moondance
08-19-2003, 09:18 AM
I have a simple customer form.

The forms action is mail.php, a script that will process and send the mail to my email address.

Is there a way to include in this php script a small, self-closing "thank you" window? Whenever i try i get the warning that "the header information has already been sent" - because i use header - location to take the user back to the form page.

Anyway around this?

heres my mail.php
<?

//Contents of form
$name=$_POST['Name'];
$company = $_POST['Company'];
$email=$_POST['Email'];
$message=$_POST['Message'];

//Declare the variables
$recipient = "someone@somewhere.co.uk";
$subject = "Form Submission";
$content = "The user $name from $company just filled in the contact form from the website. Their return email address is $email and they said: $message";

//mail() function sends the mail
mail($recipient,$subject,$content,$email);

//This line returns to contact page
header("Location: http://www.mycompany.co.uk/contact.htm");
?>


So i was wondering if i could put this in the above script somewhere (or if theres no equivalent php function).

<script language = "javascript">
function popMe()
{
window.open("thanks.html", "", width ="250", height = "300", status=yes, toolbar=no,menubar=no")
}
</script>

<body onload = "popMe()">


Then in the thanks.html page, to make it self-close:

<script language = "Javascript">
function closeMe()
{
setTimeout("self.close()",2000);
}
window.onload=closeMe()
</script>



Thanks for the help

cleromancer
08-19-2003, 11:42 PM
set a meta refresh instead of setting the location. Use the example, set it to zero seconds, so it does the pop up and transfers immediately. :)

--Extract from manual--
Specifies a delay in seconds before the browser automatically reloads the document. Optionally, specifies an alternative URL to load. E.g.
<META HTTP-EQUIV="Refresh" CONTENT="3;URL=http://www.some.org/some.html">

moondance
08-20-2003, 03:34 AM
i'm not quite sure i follow - whats a meta refresh?

And where do i put this? when i put into the web page with the contact form the page reloads rapidly: should i be putting it in the mail.php script (the one that processes the form data), and do i need to use the javascript above as well?

thanks for your reply

cleromancer
08-21-2003, 02:15 AM
since you are already using javascript, you can do it this way. but a meta refresh goes in <head>


<script language = "javascript">
<!--
window.open("thanks.html", "", width ="250", height = "300", status="yes", toolbar="no",menubar="no")
window.location = "http://www.mycompany.co.uk/contact.htm";
-->
</script>