PHP程序里面
各位大神,求助下,關(guān)于網(wǎng)站表單發(fā)布后的回調(diào),前端發(fā)布回調(diào),參考:http://m.apdwn.com/doc/897.html 寫(xiě)回調(diào), 沒(méi)問(wèn)題,但是如果我是在網(wǎng)站會(huì)員中心發(fā)布的網(wǎng)站表單,就不能回調(diào)了,也就是這個(gè)地址發(fā)布的可以回調(diào):http://ooxx.com/index.php?s=form&c=zixun&m=post 但是這個(gè)地址發(fā)布的不能回調(diào)http://ooxx.com/index.php?s=member&app=form&c=zixun&m=add。求助了下老大,老大說(shuō)會(huì)員中心的網(wǎng)站表單發(fā)布沒(méi)有寫(xiě)回調(diào)方法,只能在這邊求助下大神們,我需要在會(huì)員中心網(wǎng)站表單發(fā)布后,調(diào)用回調(diào)完成另外一個(gè)表的更新和消息的發(fā)送。有什么方法可以做到,謝謝了!
發(fā)一下控制器的代碼,index.php?s=member&app=form&c=zixun&m=add。和前端控制器稍微改下就行了
開(kāi)源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問(wèn)題!
控制器里面加一個(gè)這個(gè)啊,一樣的原理
// 新增回調(diào)函數(shù) protected function _Call_Post($data) { $cp = parent::_Call_Post($data); if ($cp['code']) { // 這里寫(xiě) 提交成功時(shí)的 你的程序代碼 $this->_json($cp['code'], '提交表單成功', $cp['data']); } else { $this->_json(0, '提交失敗', $cp['data']); } }回復(fù)@官方研發(fā)技術(shù)-實(shí)習(xí) 大神,您好,我復(fù)制了個(gè)add方法,改名為hufu。代碼如下,麻煩您看下!
public function hufw() { $qid = \Phpcmf\Service::L('input')->get('qid'); $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); if(IS_POST){ $_POST["data"]["title"] = $cc["title"]; $_POST["data"]["glzlid"] = $cc["glzlid"]; $_POST["data"]["sjlx"] = '1'; list($tpl) = $this->_Post(0); } \Phpcmf\Service::V()->assign([ 'cc' => $cc, ]); \Phpcmf\Service::V()->display('form_hf.html'); } // 新增回調(diào)函數(shù) protected function _Call_Post($data) { $cp = parent::_Call_Post($data); //自己業(yè)務(wù)處理 // exit("222"); $qid = $data["1"]["hfwtid"]; $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); //更新關(guān)聯(lián)問(wèn)題的狀態(tài)為已回復(fù) $dataa = array( 'shifouhuifu' => '1', ); \Phpcmf\Service::M()->db->table('1_form_zixun')->where('id', $qid)->update($dataa); $datab = array( 'uid' => $cc["uid"], 'author' => $cc["author"], ); \Phpcmf\Service::L('Notice')->send_notice('item_0_2', $datab); if ($cp['code']) { // 這里寫(xiě) 提交成功時(shí)的 你的程序代碼 $this->_json($cp['code'], '提交表單成功', $cp['data']); } else { $this->_json(0, '提交失敗', $cp['data']); } }你這個(gè)代碼不全面,需要把控制器的全部代碼發(fā)來(lái)
回復(fù)@叢林灰太狼
開(kāi)源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問(wèn)題!
回復(fù)@鄭中建 嗯,我就是加這個(gè),但是不執(zhí)行,在父級(jí)_Save方法中被攔截了,您可以試下,有可能是我姿勢(shì)不對(duì) ??
回復(fù)@官方研發(fā)技術(shù)-實(shí)習(xí) 好呢 下面是全部代碼,麻煩您看下
<?php namespace Phpcmf\Controllers\Member; /** * 二次開(kāi)發(fā)時(shí)可以修改本文件,不影響升級(jí)覆蓋 */ class Zixun extends \Phpcmf\Member\Form { public function index() { $where = 'sjlx=0'; // 新的條件組合 if ($this->init['where_list']) { $this->init['where_list'].= ' AND '.$where; // 考慮到父類也許有可能會(huì)自帶條件,防止被覆蓋默認(rèn)條件,所以追加一個(gè) AND } else { $this->init['where_list'] = $where; } $this->_Member_List(); } public function add() { $this->_Member_Add(); } public function hlist() { \Phpcmf\Service::V()->display('form_hlist.html'); } //region 回復(fù)內(nèi)容相關(guān) public function hufw() { $qid = \Phpcmf\Service::L('input')->get('qid'); $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); if(IS_POST){ $_POST["data"]["title"] = $cc["title"]; $_POST["data"]["sjlx"] = '1'; list($tpl) = $this->_Post(0); } \Phpcmf\Service::V()->assign([ 'cc' => $cc, ]); \Phpcmf\Service::V()->display('form_hf.html'); } // 新增回調(diào)函數(shù) protected function _Call_Post($data) { $cp = parent::_Call_Post($data); //自己業(yè)務(wù)處理 // exit("222"); $qid = $data["1"]["hfwtid"]; $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); //更新關(guān)聯(lián)問(wèn)題的狀態(tài)為已回復(fù) $dataa = array( 'shifouhuifu' => '1', ); \Phpcmf\Service::M()->db->table('1_form_zixun')->where('id', $qid)->update($dataa); $datab = array( 'uid' => $cc["uid"], 'author' => $cc["author"], ); \Phpcmf\Service::L('Notice')->send_notice('item_0_2', $datab); if ($cp['code']) { // 這里寫(xiě) 提交成功時(shí)的 你的程序代碼 $this->_json($cp['code'], '提交表單成功', $cp['data']); } else { $this->_json(0, '提交失敗', $cp['data']); } } //endregion public function edit() { $this->_Member_Edit(); } public function order_edit() { $this->_Member_Order(); } public function del() { $this->_Member_Del(); } }<?php namespace Phpcmf\Controllers\Member; /** * 二次開(kāi)發(fā)時(shí)可以修改本文件,不影響升級(jí)覆蓋 */ class Zixun extends \Phpcmf\Member\Form { public function index() { $where = 'sjlx=0'; // 新的條件組合 if ($this->init['where_list']) { $this->init['where_list'].= ' AND '.$where; // 考慮到父類也許有可能會(huì)自帶條件,防止被覆蓋默認(rèn)條件,所以追加一個(gè) AND } else { $this->init['where_list'] = $where; } $this->_Member_List(); } public function add() { $this->_Member_Add(); } public function hlist() { \Phpcmf\Service::V()->display('form_hlist.html'); } //region 回復(fù)內(nèi)容相關(guān) public function hufw() { $qid = \Phpcmf\Service::L('input')->get('qid'); $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); if(IS_POST){ $_POST["data"]["title"] = $cc["title"]; $_POST["data"]["sjlx"] = '1'; list($tpl) = $this->_Post(0); } \Phpcmf\Service::V()->assign([ 'cc' => $cc, ]); \Phpcmf\Service::V()->display('form_hf.html'); } protected function _Format_Data($id, $data, $old) { $cp = parent::_Format_Data($id, $data, $old) ; //自己業(yè)務(wù)處理 // exit("222"); $qid = $data["1"]["hfwtid"]; $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); //更新關(guān)聯(lián)問(wèn)題的狀態(tài)為已回復(fù) $dataa = array( 'shifouhuifu' => '1', ); \Phpcmf\Service::M()->db->table('1_form_zixun')->where('id', $qid)->update($dataa); $datab = array( 'uid' => $cc["uid"], 'author' => $cc["author"], ); \Phpcmf\Service::L('Notice')->send_notice('item_0_2', $datab); } //endregion public function edit() { $this->_Member_Edit(); } public function order_edit() { $this->_Member_Order(); } public function del() { $this->_Member_Del(); } }開(kāi)源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問(wèn)題!
回復(fù)@官方研發(fā)技術(shù)-實(shí)習(xí) 大神,不好意思 剛?cè)プ鲲埩耍以嚵讼?您給我的代碼,確實(shí)可以回調(diào)了,但是有個(gè)問(wèn)題,發(fā)布表單信息的時(shí)候,點(diǎn)擊按鈕沒(méi)提示了,就閃一下,我打開(kāi)數(shù)據(jù)庫(kù)看了下。信息沒(méi)保存下來(lái),只是執(zhí)行了回調(diào)的程序,本身提交的信息沒(méi)保存下來(lái),我把回調(diào)的注釋了就正常了。
protected function _Format_Data($id, $data, $old) { $cp = parent::_Format_Data($id, $data, $old);麻煩您再看下 謝謝了
protected function _Format_Data($id, $data, $old) { $cp = parent::_Format_Data($id, $data, $old) ; //自己業(yè)務(wù)處理 // exit("222"); $qid = $data["1"]["hfwtid"]; $cc = \Phpcmf\Service::M()->db->table(SITE_ID."_form_zixun")->where("id", $qid)->get()->getRowArray(); //更新關(guān)聯(lián)問(wèn)題的狀態(tài)為已回復(fù) $dataa = array( 'shifouhuifu' => '1', ); \Phpcmf\Service::M()->db->table('1_form_zixun')->where('id', $qid)->update($dataa); $datab = array( 'uid' => $cc["uid"], 'author' => $cc["author"], ); \Phpcmf\Service::L('Notice')->send_notice('item_0_2', $datab); return $cp; }開(kāi)源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問(wèn)題!
回復(fù)@官方研發(fā)技術(shù)-實(shí)習(xí) 謝謝官方大神,已經(jīng)OK了,還有個(gè)小問(wèn)題咨詢您下,我想自定義網(wǎng)站表單提交后的提示文字,如何自定義,求指導(dǎo) 謝謝!