I'm working on making an email PHP that sends me an email whenever someone completes my survey. I have all of these variables defined in my code and every single one of them works correctly and shows up in my email except the $phone variable. In that row of my code, I get a blank line. Why would that be?
<?PHP
/* message */
$name = $_POST['name'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$fulladdress = $address . ", " . $address2;
$city = $_POST['city'];
$state = $_POST['state'];
$zipcode = $_POST['zipcode'];
$city_state_zip = $city . ", " . $state . " " . $zipcode;
$email = $_POST['email'];
$phone = $_POST['phone'];
$phone = "(" . substr($phone, 0, 3). ") " . substr($phone, 3, 3) . "-" . substr($phone,6,4);
$years_experience = $_POST['years_experience'];
$education_level = $_POST['education_level'];
$salary = $_POST['salary'];
$current_employer = $_POST['current_employer'];
$previous_employer1 = $_POST['previous_employer1'];
$previous_employer2 = $_POST['previous_employer2'];
if( empty($previous_employer2) AND empty($previous_employer1) ) {
$previous_employers = "None";
}
elseif(empty($previous_employer2)) {
$previous_employers = $previous_employer1;
}
else{
$previous_employers = $previous_employer1 . " and " . $previous_employer2;
}
$grad_year = $_POST['grad_year'];
$class_size = $_POST['class_size'];
$department_feedback = $_POST['department_feedback'];
$wishes = $_POST['wishes'];
/* $size = count($useful_classes);
$classes="";
foreach ($useful_classes as $key => $value){
$classes .= $value;
if($size > ($key + 1)){
$classes .= ", ";
}
}
$size2 = count($skills);
$skillsets="";
foreach ($skills as $key => $value){
$skillsets .= $value;
if($size2 > ($key + 1)){
$skillsets .= ", ";
}
} */
$restaurant = $_POST['restaurant'];
$hobbies = $_POST['hobbies'];
$kstate_memory = $_POST['kstate_memory'];
$messageTT ="";
$messageTT .= <<<EOT
<html>
<head>
<title></title>
</head>
<body>
<table style="border-collapse: collapse">
<tr>
<td align="right" style="border: solid 1px black"> <b>Name:</b> </td>
<td align="left" style="border: solid 1px black"> $name </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Address:</b> </td>
<td align="left" style="border: solid 1px black"> $fulladdress </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> </td>
<td align="left" style="border: solid 1px black"> $city_state_zip </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Email:</b> </td>
<td align="left" style="border: solid 1px black"> $email </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Phone:</b> </td>
<td align="left" style="border: solid 1px black" $phone </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Years of Professional Experience:</b> </td>
<td align="left" style="border: solid 1px black"> $years_experience </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Education Level:</b> </td>
<td align="left" style="border: solid 1px black"> $education_level </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Salary Ranking:</b> </td>
<td align="left" style="border: solid 1px black"> $salary </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Current Employer:</b> </td>
<td align="left" style="border: solid 1px black"> $current_employer </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Past Employer(s): </b></td>
<td align="left" style="border: solid 1px black"> $previous_employers </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Graduation Year: </b> </td>
<td align="left" style="border: solid 1px black"> $grad_year </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Most Useful Classes:</b> </td>
<td align="left" style="border: solid 1px black"> $classes </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Most Useful Skills: </b> </td>
<td align="left" style="border: solid 1px black"> $skillsets </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Class Size: </b> </td>
<td align="left" style="border: solid 1px black"> $class_size </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Department Feedback: </b></td>
<td align="left" style="border: solid 1px black"> $department_feedback </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b> Wishes for Next Generation: </b></td>
<td align="left" style="border: solid 1px black"> $wishes </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Favorite Restaurant: </b> </td>
<td align="left" style="border: solid 1px black"> $restaurant </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>What You Do for Fun: </b> </td>
<td align="left" style="border: solid 1px black"> $hobbies </td>
</tr>
<tr>
<td align="right" style="border: solid 1px black"> <b>Favorite K-State Memory: </b> </td>
<td align="left" style="border: solid 1px black"> $kstate_memory </td>
</tr>
</table>
</body>
</html>
EOT;
/* recipients */
$to = "anon <anon@anon.edu>";
/* subject */
$subject = " Survey Form Submission -- " . $_POST['name'];;
//$headers = 'From: '.$_POST['email']."
";
/* To send HTML mail, you can set the Content-type header. */
$headers = "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
/* additional headers */
$headers .= 'From: '.$_POST['name'].' <'.$_POST['email'].">
";
//Next two lines for cc and bcc....
//$headers .= "Cc: birthdayarchive@example.com
";
//$headers .= "Bcc: birthdaycheck@example.com
";
/* and now mail it */
mail($to, $subject, $messageTT, $headers);
?>