问题描述
PHP的新手。我正在处理来自该联系人的联系人,这需要允许用户根据下拉列表中的选项选择他们希望消息发送给谁。我目前拥有的表单可以发送给一个用户,但是我无法使其与列表一起使用。我曾尝试使用其他方式,但没有运气。我在哪里以及如何在PHP代码中插入列表?
这是我的代码的HTML部分:
<select id="topic" name="Topic">
<option value="billing">Billing</option>
<option value="careers">Careers</option>
<option value="pickup">Pick up</option>
<option value="sales">Sales</option>
<option value="other">Tracing</option>
</select>
<form id="reused_form">
<div class="form-group">
<label >Name</label>
<input type="text" name="name" required class="form-control" placeholder="Enter Name">
</div>
<div class="form-group">
<label >Email</label>
<input type="email" name="email" required class="form-control" placeholder="Enter Email">
</div>
<div class="form-group">
<label >Phone Number</label>
<input type="number" name="number" required class="form-control" placeholder="Enter Phone Number">
</div>
<div class="form-group">
<label >Message</label>
<textarea rows="3" name="message" class="form-control" placeholder="Type Your Message"> </textarea>
</div>
<div class="form-group">
<button class="btn btn-raised btn-lg btn-warning w3-theme" type="submit">Send</button>
</div>
</form>
<div id="error_message" style="width:100%; height:100%; display:none; ">
<h4> Error </h4> Sorry there was an error sending your form.
</div>
<div id="success_message" style="width:100%; height:100%; display:none; ">
<h2 style="color:blue;">Success! Your Message was Sent Successfully.</h2>
</div>
<?PHP
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);
require_once './vendor/autoload.PHP';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['name','email','number'])->arerequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('comments')->maxLength(6000);
if($topic == 'billing') { /if billing was selected
$to = '[email protected]';
}
else if($topic == 'pickup') /other options
$to = '[email protected]';
}
else if($topic == 'sales') /other options
$to = '[email protected]';
$pp->sendEmailTo('[email protected]'); // ← Your email here*/
echo $pp->process($_POST);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)