0
我有兩個單獨的數組,我的PHP郵件格式是不同的複選框組:網絡細節和graphicdetails。只有一組將被填寫(另一個將被隱藏,除非選擇了前一個單選按鈕。)我想知道如何在PHP中正確引用它們。組合兩個單獨的數組
這是我用來獲取一個發佈,但不是兩個:
foreach($_POST['webdetails'] as $value1) {
$webdetails_msg .= "$value1\n";
}
我怎麼在裏面添加graphicdetails?複製的片段讓我警告:()提供的foreach無效參數
我不知道遠不止此PHP,這樣的解釋,將不勝感激。
-
這裏的PHP我得到一個錯誤有:
<?php
/* Set mail headers */
$myemail = "[email protected]";
$subject = "New Request";
$webdetails = $_POST['webdetails'];
$graphicdetails = $_POST['graphicdetails'];
foreach($_POST['webdetails'] as $value1) {
$webdetails_msg .= "$value1\n";
}
foreach($_POST['graphicdetails'] as $value2) {
$graphicdetails_msg .= "$value2\n";
}
/* Let's prepare the message for the e-mail */
$message = "
Details:
$webdetails_msg
$graphicdetails_msg
";
/* Send the message using mail() function */
mail($myemail, $subject, $message);
<?php exit(); } ?>
HTML爲webdetails:
<input type="checkbox" name="webdetails[ ]" id="design" value="Design" />
<input type="checkbox" name="webdetails[ ]" id="development" value="Development" />
<input type="checkbox" name="webdetails[ ]" id="web-updates" value="Web Updates" />
<input type="checkbox" name="webdetails[ ]" id="forum-template" value="Forum Template (Full)" />
<input type="checkbox" name="webdetails[ ]" id="forum-graphics" value="Forum Graphics" />
<input type="checkbox" name="webdetails[ ]" id="web-other" value="Other" />
HTML爲graphicdetails:
<input type="checkbox" name="graphicdetails[ ]" id="graphic-logo" value="Logo Design" />
<input type="checkbox" name="graphicdetails[ ]" id="graphic-social" value="Social Media Graphics" />
<input type="checkbox" name="graphicdetails[ ]" id="graphic-other" value="Other" />
是否所有''在同一'
是的,都一樣。 –