• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

这个PHP文件有什么有关问题?怎么让PHP成功写入数据库后,自动跳转这个值的链接

php 搞代码 3年前 (2022-01-24) 20次浏览 已收录 0个评论

这个PHP文件有什么问题?如何让PHP成功写入数据库后,自动跳转这个值的链接

本帖最后由 a7478729 于 2015-02-24 15:04:02 编辑

<br />defined('PCPAY_PATH') or exit;<br />class record_control extends admin_control {<br />public function add() {<br />		$uid = $this->_user['uid'];<br />		if(empty($_POST)) {<br />			$this->_pkey = 'content';<br />			$this->_ukey = 'record-add';<br />			$this->_title = '发布文章';<br />			$this->_place = '内容 » 文章管理 &#187 发布文章';<br />			$habits = (array)$this->kv->get('user_habits_uid_'.$uid);<br />			$cid = isset($habits['last_add_cid']) ? (int)$habits['last_add_cid'] : 0;<br />			$data = $this->kv->get('auto_save_record_uid_'.$uid);<br />			if($data) {<br />				!empty($data['cid']) && $cid = $data['cid'];<br />			}else{<br />				$data['intro'] = array();<br />				$data['views'] = 0;<br />			}<br />			$this->assign('data', $data);<br />			$cidhtml = $this->category->get_cidhtml_by_mid(2, $cid);<br />			$this->assign('cidhtml', $cidhtml);<br />			$edit_cid_id = '&mid=2';<br />			$this->assign('edit_cid_id', $edit_cid_id);<br />			$this->display('record_set.htm');<br />		}else{<br />			$cid = intval(R('cid', 'P'));<br />			$products = intval(R('products', 'P'));<br />			$amount = intval(R('amount', 'P'));<br />			$pc = intval(R('pc', 'P'));<br />			$data = array(<br />				'cid' => $cid,<br />				'products' => $products,<br />				'amount' => $amount,<br />				'ip' => ip2long($_ENV['_ip']),<br />			);<br />			$this->cms_content->table = 'cms_record';<br />			$id = $this->cms_content->create($data);<br />			if(!$id) {<br />				E(1, '写入内容表出错');<br />			}<br />			$this->_user['contents']++;<br />			$this->user->update($this->_user);<br />			$categorys['count']++;<br />			$this->category->update($categorys);<br />			$this->category->update_cache($cid);<br />			$data = $this->kv->delete('auto_save_record_uid_'.$uid);<br />			$habits = (array) $this->kv->get('user_habits_uid_'.$uid);<br />			$habits['last_add_cid'] = $cid;<br />			$habits = $this->kv->set('user_habits_uid_'.$uid, $ha<div>本文#来源gaodai.ma#com搞##代!^码7网</div><pre>搞代gaodaima码

bits);
//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.gaodaima.com”;
Header(“Location:$url”);
exit;
}
else{
$url=”www.baidu.com”;
Header(“Location:$url”);
exit;
}
}
}
}

<br /><br /><br /><meta charset="utf-8"><br /><title>无标题文档</title><br /><br /><br /><body><br /> <br /><br />products:<br />amount:<br />hh:<br />ff: <br />dd:<br /><br /><br /><br />

上面一个是PHP写入数据库的处理文件
一个是表单提交文件,我想要的是,比如,pc的值提交为“ff”,提交后,PHP文件成功写入数据库后,如何自动跳转”ff”值链接

			elseif($pc=="ff"){<br />				$url="www.baidu.com";<br />				Header("Location:$url"); <br />				exit;<br />			}

就是如何成功写入数据库后,自动跳转这个链接
——解决思路———————-
29行:$pc = intval(R(‘pc’, ‘P’));
都intval了,不管是hh ff 还是dd,最后$pc都为0了,所以跳不过去
另外跳转需要绝对路径:http://开头


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:这个PHP文件有什么有关问题?怎么让PHP成功写入数据库后,自动跳转这个值的链接
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址