# PHP Form Error

**URL:** <https://forum.kirupa.com/t/php-form-error/223874>\
**Category:** flash\
**Created:** [April 26, 2007, 12:34pm UTC](https://forum.kirupa.com/t/php-form-error/223874 "2007-04-26T12:34:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![xFlashStudentx](https://avatars.discourse-cdn.com/v4/letter/x/57b2e6/32.png) [@xFlashStudentx](https://forum.kirupa.com/u/xFlashStudentx)\
**Post date:** [April 26, 2007, 12:34pm UTC](https://forum.kirupa.com/t/php-form-error/223874/1 "2007-04-26T12:34:55Z")

</div>

The following is a PHP script that sends mail, but once the mail is sent, a new browser window is opening, even if I omit the code: print “&status=mail sent - we will be in touch with you shortly&”…and I’m using Load Vars to send the variables. I’m the "send: method, because when I use “sendAndLoad” it doesn’t send anything.

Here is the complete script:

\<?php  
// list all vars to be expected from the movie  
$vars = array(“name”, “email”, “cars”, “houses”);  
// and import them into the script  
foreach($vars as $var)  
if(isset($\_POST[$var]))  
$$var = $\_POST[$var];  
else  
$$var = ‘’;

// check variables  
if(strlen($name) \< 3)  
die("&status=please enter a real name&");  
if(!eregi(’^([a-z0-9.\_-])+@([^.]+.[^.]+)’, $email, $matched))  
die("&status=please enter a correct email address&");  
else if(!getmxrr($matched[2], $mxrr))  
die("&status=your mail server does not seem to exist&");

// where to send it  
// remove or configure one of the two code blocks  
// otherwise your mail will be sent to [tome@hotmail.com](mailto:tome@hotmail.com) 🙂

//\*\*\*\* this one for the selectable recipients \*\*\*\*  
$recips = array(“support” =\> "tome@hotmail.com", “account” =\> "tome@hotmail.com");  
$recip = $recips[$recip];  
// if something went wrong, send to default address  
if(empty($recip)) $recip = "tome@hotmail.com";  
// \*\*\*\*\* end selectable recipient \*\*\*\*\*\*\*\*

// \*\*\*\*\* or one fixed recipient \*\*\*\*\*\*  
$recip = "tome@hotmail.com";  
//\*\*\*\* end fixed recipient \*\*\*\*\*\*\*

// build up message  
// this code for any multiline text fields  
$message = str\_replace("\r", "  
", $message);

/ /you can rearrange this - just do not add or remove quotes  
$mailbody = "Contact form sent by  
Name: $name  
Email: $email  
Cars: $cars  
Houses: $houses

* * *

// send it off  
// note - if you omit the last part, a few servers do not send mail at all,  
// but most would show strange senders like [nobody@server17.hostingcompany.com](mailto:nobody@server17.hostingcompany.com)  
mail($recip, “Register Form”, $mailbody, “From: [tome@hotmail.com](mailto:tome@hotmail.com)”);

// and tell visitor  
//print “&status=mail sent - we will be in touch with you shortly&”;  
?\>

The problem with this script is that after the mail is sent, a browser window is opening even if I delete the last code. I don’t want any browser to open once send the mail. What do I need to change here? Thanks for any help.
