我有一个带有选择选项的表单,并且正在尝试将选项$ row [email]发布到电子邮件中,似乎什么也无法工作。我已经搜索了几个小时,似乎什么也没做。任何帮助将不胜感激。 这是表格create-mail.php
<form action="add-mail.php" method="post">
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Compose New Message</h3>
</div>
<div class="box-body">
<div class="form-group">
<select id="to" name="to" class="form-control">
<?php
$sql = "SELECT * FROM apply_job_post INNER JOIN users ON apply_job_post.id_user=users.id_user WHERE apply_job_post.id_company='$_SESSION[id_company]' AND apply_job_post.status='2'";
$result = $conn->query($sql);
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo '<option value="'.$row['id_user'].'">'.$row['email'].' '.$row['firstname'].' '.$row['lastname'].'</option>';
}
}
?>
</select>
</div>
<div class="form-group">
<input class="form-control" name="subject" placeholder="Subject:">
<input type="hidden" name="user_email" id="user_email" value="<?php echo $_post['to'];?>" />
<input type="hidden" name="co_name" id="login_user" value="<?php echo $_SESSION['name'];?>" />
</div>
<div class="form-group">
<textarea class="form-control input-lg" id="description" name="description" placeholder="Job Description"></textarea>
</div>
</div>
<div class="box-footer">
<div class="pull-right">
<button type="submit" name="create_mail" class="btn btn-primary"><i class="fa fa-envelope-o"></i> Send</button>
</div>
<a href="mailbox.php" class="btn btn-default"><i class="fa fa-times"></i> Discard</a> </div>
</div>
</form>
这是add-mail.php
<?php
session_start();
if(empty($_SESSION['id_company'])) {
header("Location: ../index.php");
exit();
}
require_once("../db.php");
if(isset($_POST['create_mail']))
{
$to = mysqli_real_escape_string($conn, $_POST['to']);
$subject = mysqli_real_escape_string($conn, $_POST['subject']);
$message = "You have a message from"." ". $_POST['co_name'] ."\r\n";
$message .= "Message:"." ". $_POST['description'];
$headers[] = 'MIME-VERSION: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'To: '.$to;
$headers[] = 'From: me@mycompany.com';
$result = mail($to, $subject, $message, implode("\r\n", $headers));
}
?>