php发送消息包含复选框数组
我想让php将productsq复选框作为数组,并在消息中发送它 这不是代码,只是代码的一部分 这是html部分php发送消息包含复选框数组,php,html,message,checkbox,Php,Html,Message,Checkbox,我想让php将productsq复选框作为数组,并在消息中发送它 这不是代码,只是代码的一部分 这是html部分 这是php部分 <?php $productsqu= implode(',',mysql_real_escape_string($_post['productsq'])); $message = '<html><body>'; $message .= '<table rules="all" style="border-c
这是php部分
<?php
$productsqu= implode(',',mysql_real_escape_string($_post['productsq']));
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>products:</strong>
$message .= "<tr style='background: #eee;'><td><strong>comments:</strong> </td> <td>" .clean_string($_POST['comments']) . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>selectionField:</strong> </td><td>" .clean_string($_POST['selectionField']) . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>products:</strong> </td><td>" .clean_string($productsqu) ."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
?>
根据你的复选框
$\u POST['productsq']
是一个数组
$productsqu = mysql_real_escape_string(implode(", ", $_POST['productsq'])) ; //Implode into string first
所以,首先将数组内爆为字符串,然后在其上使用
mysql\u real\u escape\u string()
。尝试下面的代码,希望它能对您有所帮助
<?php
if(isset($_POST['submit']) == 'submit')
{
$productsqu= mysql_real_escape_string(implode(',',$_POST['productsq']));
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>products:</strong>";
$message .= "<tr style='background: #eee;'><td><strong>comments:</strong> </td> <td>" .$_POST['comments'] . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>selectionField:</strong> </td><td>" .$_POST['selectionField']. "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>products:</strong> </td><td>" .$productsqu."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
echo $message;
}
?>
我知道解决方案是这样的:$productsq=内爆(“,”,$\u POST['productsq']);
<?php
if(isset($_POST['submit']) == 'submit')
{
$productsqu= mysql_real_escape_string(implode(',',$_POST['productsq']));
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>products:</strong>";
$message .= "<tr style='background: #eee;'><td><strong>comments:</strong> </td> <td>" .$_POST['comments'] . "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>selectionField:</strong> </td><td>" .$_POST['selectionField']. "</td></tr>";
$message .= "<tr style='background: #eee;'><td><strong>products:</strong> </td><td>" .$productsqu."</td></tr>";
$message .= "</table>";
$message .= "</body></html>";
echo $message;
}
?>
$message .= "<tr style='background: #eee;'><td><strong>products:</strong>";