我正在创建一个获取某些字段的申请表,例如某人的名字、姓氏、电子邮件、部门等,并将该信息提交到电子邮件表单中。一切正常,但我希望用户选择的部门显示在电子邮件的主题行中。我将该部分设置为一个选项,而不是让用户输入它并在我的 PHP 电子邮件文件中使用 $_POST。我确定这是次要的,但我不确定应该如何完成。有什么建议吗?提前致谢
----------------------------------------这是 HTML 代码----- --------
<body style="padding:3px; margin:0px;" bgcolor="#FFFFFF">
<center>
<table cellpadding="0" cellspacing="0" border="0" width="440">
<tr><td style="height:10px"></td></tr>
<tr>
<td colspan="2" style="text-align:justify; line-height:15px;" class="body">
<form name="frm" method="POST" action="php file" enctype="multipart/form-data">
<center>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
.........
.........
.........
<tr><td style="height:3px"></td></tr>
<tr>
<td width = "23%" class="body">Departments</td>
<td width = "3%" class ="body">:</td>
<td width="74%">
<select>
<option value="departments" name = "departments">Engineering</option>
<option value="departments" name = "departments">Marketing</option>
<option value="departments" name = "departments">PR/Social</option>
<option value="departments" name = "departments">Media</option>
</select>
</td>
</tr>
--------------------PHP----------------------------
<?php
if(!empty($_FILES['resume_name']['name'])){
$file_name=$_FILES['resume_name']['name'];
$temp_name=$_FILES['resume_name']['tmp_name'];
$file_type=$_FILES['resume_name']['type'];
$file_size=$_FILES['resume_name']['size'];
$base=basename($file_name);
$extension= pathinfo($base, PATHINFO_EXTENSION);
$allowed_ext=array("doc","docx","pdf","zip","jpeg","jpg","txt");
if (in_array($extension,$allowed_ext)){
$from=$_POST['email'];
$fname=$_POST['first_name'];
$lname=$_POST['last_name'];
$to="travis.dacosta1@gmail.com";
$subject= $departments;
$credentials=$_POST['qualifications'];
$message=
' The person that contacted you is: '.$fname.' '.$lname.'
E-mail: '.$from.'
Subject: '$subject'
Qualifications: '.$credentials.'
|---------END MESSAGE----------|';
$file=$temp_name;
$content = chunk_split(base64_encode(file_get_contents($file)));
//$content = chunk_split(base64_encode(file_get_contents($content)));
$uid=md5(uniqid(time()));
$header = "From: ". $from. "\r\n";
$header .= "Reply-To: ". $replyto. "\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .="Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type: ".$file_type."; name=\"".$file_name."\"\r\n";
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: resume_name; file_name=\"".$file_name."\"";
$header .= $content."\r\n\r\n";
if(@mail($to, $subject, $message, $header)){
echo "Success";
}
exit();
?>