2015-09-28 150 views
1
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新手。注意:數組到字符串轉換

回答

2

implode是你的朋友在這裏。而不僅僅是echo的價值,使用它:

if (isset($_POST['emaildistribution'])) 
{ 
    $_POST['emaildistribution']) = implode(',', $_POST['emaildistribution']);  
} 
+0

謝謝你工作得很好。 – Alex

相關問題