What is the problem with this php file? How to enable PHP to automatically jump to this value link after writing data to the database

Source: Internet
Author: User
Tags ukey
What is the problem with this php file? How to enable PHP to automatically jump to this value link after writing data to the database
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 = 'Post '; $ this-> _ place = 'content> article management> publish topic'; $ 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 ['View'] = 0;} $ this-> assign ('data', $ data); $ cidhtml = $ this-> category-> get_cidhtml_by_mid (2, $ cid); $ this-> assign ('cida', $ cidhtml); $ edit_cid_id = '& mid = 2'; $ this-> assign ('edit _ ciid_id ', $ edit_cid_id); $ this-> display('record_set.htm');} else {$ cid = intval (R ('CID', 'P ')); $ products = intval (R ('products', 'P'); $ amount = int Val (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, 'Write content table error');} $ this-> _ user ['tents'] ++; $ 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, 'publish finished '. $ ends Tr); 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 ;}}}}

 Untitled Document


The above is the processing file written to the database by PHP.
For example, if the pc value is submitted as "ff" and the PHP file is successfully written to the database after submission, how can I automatically jump to the "ff" value link?
elseif($pc=="ff"){$url="www.baidu.com";Header("Location:$url"); exit;}
This is how to automatically jump to this link after the database is successfully written.


Reply to discussion (solution)

29 rows: $ pc = intval (R ('PC', 'P '));
All intval, whether it is hh ff or dd, and the last $ pc is 0, so it cannot jump.
In addition, the jump must start with "http: //".

29 rows: $ pc = intval (R ('PC', 'P '));
All intval, whether it is hh ff or dd, and the last $ pc is 0, so it cannot jump.
In addition, the jump must start with "http: //".


I have changed this problem, but it cannot jump over. after the database is successfully written, the page is blank.

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 = 'Post '; $ this-> _ place = 'content> article management> publish topic'; $ 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 ['View'] = 0;} $ this-> assign ('data', $ data); $ cidhtml = $ this-> category-> get_cidhtml_by_mid (2, $ cid); $ this-> assign ('cida', $ cidhtml); $ edit_cid_id = '& mid = 2'; $ this-> assign ('edit _ ciid_id ', $ edit_cid_id); $ this-> display('record_set.htm');} else {$ cid = intval (R ('CID', 'P ')); $ products = intval (R ('products', 'P'); $ amount = int Val (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, 'Write content table error');} $ this-> _ user ['tents'] ++; $ 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, 'publish finished '. $ ends Tr); if (! $ Data-> E (0, $ endstr) {exit;} elseif ($ pc = "1") {$ url =" http://www.w3school.com.cn "; Header (" Location: $ url "); exit;} elseif ($ pc =" 2 ") {$ url =" www.baidu.com "; Header (" Location: $ url "); exit;} elseif ($ pc =" 3 ") {$ url =" bbs.csdn.net "; Header (" Location: $ url "); exit ;} else {$ url =" http://www.baidu.com "; Header (" Location: $ url "); exit ;}}}}
What's the problem?

29 rows: $ pc = intval (R ('PC', 'P '));
All intval, whether it is hh ff or dd, and the last $ pc is 0, so it cannot jump.
In addition, the jump must start with "http: //".


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 = 'Post '; $ this-> _ place = 'content> article management> publish topic'; $ 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 ['View'] = 0;} $ this-> assign ('data', $ data); $ cidhtml = $ this-> category-> get_cidhtml_by_mid (2, $ cid); $ this-> assign ('cida', $ cidhtml); $ edit_cid_id = '& mid = 2'; $ this-> assign ('edit _ ciid_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, 'Write content table error');} elseif ($ pc = "1") {$ url =" http://www.w3school.com.cn "; Header (" Location: $ url "); exit;} elseif ($ pc =" 2 ") {$ url =" www.baidu.com "; Header (" Location: $ url "); exit;} elseif ($ pc =" 3 ") {$ url =" bbs.csdn.net "; Header (" Location: $ url "); exit ;} else {$ url =" http://www.baidu.com "; Header (" Location: $ url "); exit ;}}}}
That's all. thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.