以下是我保存数据的代码:
function save_new_exam(){
extract($_POST);
global $wpdb;
$wpdb->insert(
\'wp_absb_exam_setting\',
array(
\'name\' => $name,
\'time\' => $time,
\'status\' => 1,
\'user_id\' => get_current_user_id()
),
array(
\'%s\',
\'%s\',
\'%d\',
\'%d\'
)
);
do_action( \'admin_notices\', \'new_exam_created\' );
}
function new_exam_created(){
?>
<div class="notice notice-success is-dismissible">
<p> Saved successfully!</p>
</div>
<?php }
以下是表格代码:
<form method="post" action="<?php echo $_SERVER[\'REQUEST_URI\']; ?>">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row">
<label for="mail_from"><?php _e("Exam Title"); ?></label>
</th>
<td>
<input name="name" type="text" value="" size="40" class="regular-text">
<p class="description">
Give a Meaningful Exam Title.
</p>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="mail_from"><?php _e("Exam Time"); ?></label>
</th>
<td>
<input name="time" type="text" value="" size="40" class="regular-text">
<p class="description">
Set exam time as HH:MM:SS format.
</p>
</td>
</tr>
</tbody>
</table>
<p class="submit">
<input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes">
</p>
</form>
当我提交表单时,数据正在保存,但没有显示管理通知。我的代码中有什么问题?我在google上搜索了几个小时,但没有成功。请帮忙!