如何在php中为消息传递系统选择多个用户
我正在为消息传递系统使用PHP和HTMl。为了从db中获取用户列表,我使用了select查询和while循环在html下拉列表中列出用户名。 我的问题是,如何一次选择两个或多个用户向他们发送消息。有谁能在这方面指导我吗如何在php中为消息传递系统选择多个用户,php,html,phpmyadmin,Php,Html,Phpmyadmin,我正在为消息传递系统使用PHP和HTMl。为了从db中获取用户列表,我使用了select查询和while循环在html下拉列表中列出用户名。 我的问题是,如何一次选择两个或多个用户向他们发送消息。有谁能在这方面指导我吗 <div class="content"> <h1>New Personnal Message</h1> <form action="message.php" method="post"> Please fill the f
<div class="content">
<h1>New Personnal Message</h1>
<form action="message.php" method="post">
Please fill the following form to send a personnal message.<br /><br />
<label>Title</label>
<div class="text">
<input type="text" value="<?php echo htmlentities($otitle, ENT_QUOTES, 'UTF-8'); ?>" id="title" name="title" /><br /><br /></div>
<label for="recip">Recipient<span class="small"> (Username)</span></label>
<div class="text">
<input type='checkbox' onclick="checkall()" id="selectall">
<?php
$sql2 = "SELECT fname FROM REGISTRATIONFORM";
$result2 = $conn->query($sql2);
echo "<select name='username'>";
while ($row = $result2->fetch_assoc())
{
echo "<option value='".$row['fname']."'>" .$row['fname']."</option>";
}
echo "</select>";
?>
<br /><br />
</div>
<?php
else
{
?>
<label for="recip">Recipient<span class="small"> (Username)</span></label>
<div class="text">
<input type="text" readonly value="<?php echo $email; ?>" id="recip" name="recip" /><br /><br /></div>
<?php
}
?>
<label for="message">Message</label>
<div class="text">
<textarea cols="40" rows="5" id="message" name="message"><?php echo htmlentities($omessage, ENT_QUOTES, 'UTF-8'); ?></textarea></div><br /><br />
<div class="text">
<input type="submit" value="Send" class="btn btn-info"/><br /><br /><br />
</div>
</form>
新的个人信息
请填写以下表格以发送个人信息。
标题
收件人(用户名)
添加多个属性以选择如下所示
echo "<select name='username[]' multiple>";
echo”“;
使用CTRL+单击选择更多
如果您的问题是如何使用php发送邮件,您可以在此处找到更多信息在处理多选下拉列表时,需要记住两件事:
echo "<select name='username[]' multiple>";
谢谢你的回答@mayank。我需要如何使用post方法获取这些用户名值,并在数据库中插入这些值。
$usernames = $_REQUEST['username'];
foreach($usernames as $username)
{
// your logic here
}