【发布时间】:2016-01-18 04:04:06
【问题描述】:
当它调用 mysave.php 文件时,我得到错误调用一个非对象上的成员函数 insert()需要放到根目录下。
<style>
form#my > #phase2{ display:none; }
</style>
<script>
function _(x){
return document.getElementById(x);
}
function processPhase1(){
_("phase1").style.display = "none";
_("phase2").style.display = "block";
}
function submitForm(){
_("myform").method = "post";
_("myform").action = "mysave.php";
_("myform").submit();
}
</script>
<form id="myform" onsubmit="return false" >
<div id="phase1">
<input type="text" id="inputbook" name="bookname" placeholder="book name" height="34px">
<button onclick="processPhase1()"><strong>Next</strong></button>
<div>
<div id="phase2">
<input type="text" id="inputcode" name="code" placeholder="code" height="34px">
<button onclick="submitForm()"><strong>SUBMIT</strong></button>
<div>
</form>
mysave.php
if(isset($_POST['bookname']))
{
global $wpdb;
$bookname=$_POST['bookname'];
$code=$_POST['code'];
$todaydate = new DateTime();
$todaydate =$todaydate->format('Y-m-d H-i-s');
$bookpost= array('post_type'=>'books',
'post_title'=>$bookname,
'post_author'=>'1',
'post_status'=>'publish',
'post_date'=>$todaydate );
$wpdb->insert('wp_posts',$bookpost);
$Cid=$wpdb->insert_id;
update_field('code',$code,$Cid);
}
【问题讨论】:
-
你能补充更多关于你的问题的信息吗?