所选选项值未显示在电子邮件中



我可以成功发送电子邮件,但所选值未显示在电子邮件中。 $select是应该显示的。请帮助我..

代码如下:

if (isset($_POST['submit']) && isset($_POST['sendMail'] ) )
{
$select = $_POST['datanew[co_cd]'];
$email = "example@gmail.com";
$message = '<tr> <td><h2><strong>Dear </strong>'.  $select.' 
<h3>We would like to update you about your transaction with below details. <br>
BL #'.$datanew[bl_no]."
Container #:  6PK<br>
Recent Updates as of " . date('F d,Y   h:i A') . " </h3></td><tr> " ;
$headers  = 'mime_content_type(filename)E-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$headers .= "From: example@gmail.com" . "rn";
mail($email,"Worksheet",$message, $headers);
}

else{
}

视图页中的代码:

<select class="form-control" name="datanew[co_cd]">
<option value="">Choose Client</option>
<?php foreach($client as $clientrow) : 
if 
($transdbrow['co_cd']===$clientrow['co_cd']) {
echo '<option value="' . $clientrow['co_cd'] . '" selected>' . 
$clientrow['co_name'] . '</option>';
} 
else {
echo '<option value="' . $clientrow['co_cd'] . '">' . $clientrow['co_name'] 
. '</option>';
}
endforeach;
$client = $client;?>                            
</select>

PHP 会将您的选择名称解释为一个名为datanew的数组,因此访问该值的正确方法是

$select = $_POST['datanew']['co_cd'];

相关内容

  • 没有找到相关文章

最新更新