if (isset($_POST['emaildistribution']))
{
echo implode(',', $_POST['emaildistribution']);
}
$first_name = $_POST['Fname'];
$last_name = $_POST['Lname'];
$city = $_POST['city'];
$department = $_POST['department'];
$day = $_POST['day'];
$tick = $_POST['tick'];
$staffName = $_POST['staffName'];
$permissions = $_POST['permGranted'];
$PersonalComp = $_POST['PersonalComp'];
$deskPhone = $_POST['deskPhone'];
$mobPhone = $_POST['mobPhone'];
$field = $_POST['field'];
$submit = $_POST['confirm'];
$headers = 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>First Name:</strong> </td><td>" . strip_tags($_POST['Fname']) . "</td></tr>";
$message .= "<tr><td><strong>Last Name:</strong> </td><td>" . strip_tags($_POST['Lname']) . "</td></tr>";
$message .= "<tr><td><strong>Location:</strong> </td><td>" . strip_tags($_POST['city']) . "</td></tr>";
$message .= "<tr><td><strong>Department:</strong> </td><td>" . strip_tags($_POST['department']) . "</td></tr>";
$message .= "<tr><td><strong>Date:</strong> </td><td>" . $_POST['day'] . "</td></tr>";
$message .= "<tr><td><strong>Permissions as Other User:</strong> </td><td>" . strip_tags($_POST['tick']) . "</td></tr>";
$message .= "<tr><td><strong>Other User:</strong> </td><td>" . $_POST['staffName'] . "</td></tr>";
$message .= "<tr><td><strong>Permissions:</strong> </td><td>" . strip_tags($_POST['permGranted']) . "</td></tr>";
$message .= "<tr><td><strong>Hardware:</strong> </td><td>" . $_POST['PersonalComp'] . "</td></tr>";
$message .= "<tr><td><strong>New Equipment:</strong> </td><td>" . strip_tags($_POST['deskPhone']) . "</td></tr>";
$message .= "<tr><td><strong>Desk Phone:</strong> </td><td>" . $_POST['mobPhone'] . "</td></tr>";
$message .= "<tr><td><strong>Mobile Phone :</strong> </td><td>" . strip_tags($_POST['field']) . "</td></tr>";
$message .= "<tr><td><strong>Email Distribtuion Groups :</strong> </td><td>" . ($_POST['emaildistribution']) . "</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
if(isset($submit)) {
// EDIT THE LINES BELOW AS REQUIRED WHENEVER EMAIL CHANGES
mail($email_to,$email_subject,$message,$headers);
echo "<p>Thank you! Your message has been sent.</p>";
}
?>
如果我使用序列化代码执行完美,但我不想要它发送的所有额外信息,因为它看起来不整洁。有没有一种简单的方法可以将emaildistribution(一个数组)转换为字符串,以便通过POST传递?我是PHP的新手。
答案 0 :(得分:2)
implode
是你的朋友。而不只是echo
值,使用它:
if (isset($_POST['emaildistribution']))
{
$_POST['emaildistribution']) = implode(',', $_POST['emaildistribution']);
}