What is wrong with this PHP if statement?

Geek Squad

New member
<?php
if($POST_["to2"] != "")
{
$to = $_POST["to"] . ', ';
$to .= $_POST["to2"];
}
else
{
$to = $_POST["to"];
}
$subject = $_POST["subject"];
$message = $_POST["message"];
$from = $_POST["from"];
$name = $_POST["name"];
$headers = 'From: ' . $name . ' <' . $from . ' >' . "\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to, $subject, $message, $headers);
echo '<script type="text/javascript">
history.go(-1)
</script>';
?>

This script only sends the email to the first person even IF to2 isn't blank.
Apparently to2 is blank, yet the input is filled in with an e-mail address. How is this possible?
 
Seems $POST_["to2"] is always empty . Try echoing its value at the beginning of the script and see
 
Seems $POST_["to2"] is always empty . Try echoing its value at the beginning of the script and see
 
Back
Top