问题
我无法找到适合我需要的插件。我想要一个可以添加成员的表单,并保存到数据库并查询所有它,它可以通过csv格式导出。我使用Insert PHP插件并在我的页面中添加纯PHP代码,但它不会起作用。有人能帮帮我吗?谢谢。
代码
[insert_php]
if(isset($_POST['save'])){
$field1 = $_POST['name'];
$field2 = $_POST['email'];
$field3 = $_POST['address'];
$field4 = date("M d,Y H:i:s");
$wpdb = prepare("INSERT INTO backend-member (field1,field2,field3,field4) VALUES (:field1,:field2,:field3,:field4)");
$wpdb->bindParam(':field1', $field1);
$wpdb->bindParam(':field2', $field2);
$wpdb->bindParam(':field3', $field3);
$wpdb->bindParam(':field4', $field4);
$wpdb->execute();
}
[/insert_php]
<form action="" method="POST">
<ul class="form-style-1">
<li><label>Navn <span class="required">*</span></label><input class="field-long" name="field1" type="text" placeholder="Navn" /></li>
<li><label>Mobil<span class="required">*</span></label>
<input class="field-long" name="field2" type="text" /></li>
<li><label>Email <span class="required">*</span></label>
<input class="field-long" name="field3" type="email" /></li>
<li><label>Facebook<span class="required">*</span></label>
<input class="field-long" name="field4" type="text" /></li>
<li><input name="save" type="submit" value="Submit" /></li>
</ul>
</form>