我在我的 wordpress 数据库中创建了一个带有表单和新表的自定义页面wp_applicants
。当我提交时,它会返回结果回显消息,但不会插入到我的数据库表中。请协助。
编码:
<?php
/**
*Template Name: Career Temp
*/
get_header();
?>
<div class="page-header-wrap">
<header class="page-header">
<h1 class="page-header-title"><?php the_title(); ?></h1>
</header>
</div>
<div id="primary" class="content-area span_16 col clr clr-margin">
<div id="content" class="site-content" role="main">
<!-- paul removed post loop -->
<?php
if(isset($_POST['submit'])) {
global $wpdb;
$fname=$_POST['txt_fname'];
$lname=$_POST['txt_lname'];
$tbl="wp_applicants";
$others= $_POST['txt_email'];
$wpdb->insert('wp_applicants', array('first_name' => $fname, 'last_name' => $lname, 'email' => $others), array('%s', '%s', '%s'));
$msg = "Data Submited";
echo $msg;
}
?>
<form action="" method="post">
first name - <input type="text" name="txt_fname"/>
last name - <input type="text" name="txt_lname"/>
email - <input type="text" name="txt_email"/>
<input type="submit" name="submit"/>
</form>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>