這個PHP檔案有什麼有關問題?怎麼讓PHP成功寫入資料庫後,自動跳轉這個值的連結

來源:互聯網
上載者:User
這個PHP檔案有什麼問題?如何讓PHP成功寫入資料庫後,自動跳轉這個值的連結
本帖最後由 a7478729 於 2015-02-24 15:04:02 編輯


defined('PCPAY_PATH') or exit;
class record_control extends admin_control {
public function add() {
$uid = $this->_user['uid'];
if(empty($_POST)) {
$this->_pkey = 'content';
$this->_ukey = 'record-add';
$this->_title = '發布文章';
$this->_place = '內容 » 文章管理 » 發布文章';
$habits = (array)$this->kv->get('user_habits_uid_'.$uid);
$cid = isset($habits['last_add_cid']) ? (int)$habits['last_add_cid'] : 0;
$data = $this->kv->get('auto_save_record_uid_'.$uid);
if($data) {
!empty($data['cid']) && $cid = $data['cid'];
}else{
$data['intro'] = array();
$data['views'] = 0;
}
$this->assign('data', $data);
$cidhtml = $this->category->get_cidhtml_by_mid(2, $cid);
$this->assign('cidhtml', $cidhtml);
$edit_cid_id = '&mid=2';
$this->assign('edit_cid_id', $edit_cid_id);
$this->display('record_set.htm');
}else{
$cid = intval(R('cid', 'P'));
$products = intval(R('products', 'P'));
$amount = intval(R('amount', 'P'));
$pc = intval(R('pc', 'P'));
$data = array(
'cid' => $cid,
'products' => $products,
'amount' => $amount,
'ip' => ip2long($_ENV['_ip']),
);
$this->cms_content->table = 'cms_record';
$id = $this->cms_content->create($data);
if(!$id) {
E(1, '寫入內容表出錯');
}
$this->_user['contents']++;
$this->user->update($this->_user);
$categorys['count']++;
$this->category->update($categorys);
$this->category->update_cache($cid);
$data = $this->kv->delete('auto_save_record_uid_'.$uid);
$habits = (array) $this->kv->get('user_habits_uid_'.$uid);
$habits['last_add_cid'] = $cid;
$habits = $this->kv->set('user_habits_uid_'.$uid, $habits);
//E(0, '發布完成'.$endstr);
if(!$data->E(0,$endstr)){
echo $errormsg;
}
elseif($pc=="hh"){
$url="www.w3school.com.cn";
Header("Location:$url");
exit;
}
elseif($pc=="ff"){
$url="www.baidu.com";
Header("Location:$url");
exit;
}
elseif($pc=="dd"){
$url="bbs.csdn.net";
Header("Location:$url");
exit;
}
else{
$url="www.baidu.com";
Header("Location:$url");
exit;
}
}
}
}





無標題文檔







上面一個是PHP寫入資料庫的處理檔案
一個是表單提交檔案,我想要的是,比如,pc的值提交為“ff”,提交後,PHP檔案成功寫入資料庫後,如何自動跳轉"ff"值連結
elseif($pc=="ff"){
$url="www.baidu.com";
Header("Location:$url");
exit;
}
就是如何成功寫入資料庫後,自動跳轉這個連結
------解決思路----------------------
29行:$pc = intval(R('pc', 'P'));
都intval了,不管是hh ff 還是dd,最後$pc都為0了,所以跳不過去
另外跳轉需要絕對路徑:http://開頭
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.