欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

提交后获取不到值

程序员文章站 2022-05-31 09:55:07
...
提交后只能获取到时间 但获取不到input的值

PHP
public function _FeedBack(){$post = $this->input->post(NULL, TRUE);$ac=$_REQUEST['ac'];if($ac=='activityuser_sn'){ $post['addtime'] = time();$post['txt_Name'] = $tel; $this->asdasd->insert($post);$prize_arr =array('success'=>'true'); //这是提交后填写订单成功的echo json_encode($prize_arr);}}


html



js
$(function() {	window.requestAnimFrame = (function() {		return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||		function(callback) {			window.setTimeout(callback, 1000 / 60)		}	})();	var totalDeg = 360 * 3 + 0;	var steps = [];	var lostDeg = [36, 66, 96, 156, 186, 216, 276, 306, 336];	var prizeDeg = [6, 126, 246]; 	//var lostDeg = [36, 66, 96, 156, 186, 216, 276, 306, 336];	//var prizeDeg = [6,36, 66, 96, 126,156, 186, 216,246, 276, 306, 336];	var prize, sncode;	var count = 0;	var now = 0;	var a = 0.01;	var strmsg;	var outter, inner, timer, running = false;	function countSteps() {		var t = Math.sqrt(2 * totalDeg / a);		var v = a * t;		for (var i = 0; i = 2) {			alert("已经 2 次了。");			return		}		if (prize != null) {			alert("不能再参加了");			return		}		$.ajax({			url: "http://127.0.0.1/index.php",			dataType: "json",			data: {				token: "o7MB9ji5fQRsE0ZoVAMU7SlnRyMI",				ac: "activityuser",				tid: "5",				t: Math.random()			},			beforeSend: function() {				running = true;				timer = setInterval(function() {					i += 5;					outter.style.webkitTransform = 'rotate(' + i + 'deg)';					outter.style.MozTransform = 'rotate(' + i + 'deg)'				},				1)			},			success: function(data) {				if (data.error == "invalid") {					alert("已经3 次了。");					count = 3;					clearInterval(timer);					return				}				if (data.error == "getsn") {					alert('已经中过,SN码为:' + data.sn);					count = 3;					clearInterval(timer);					prize = data.prizetype;					sncode = data.sn;					start(prizeDeg[data.prizetype - 1]);					return				}				if (data.success) {					prize = data.prizetype;					sncode = data.sn;					//start(prizeDeg[data.prizetype - 1])					start(data.angle)				}								//if (data.error) {				else{					prize = null;					start()									}								running = false;				count++			},						error: function() {								prize = null;				start();				running = false;				count++			},						timeout: 4000		})	})});$("#save-btn").bind("click",function() {	var btn = $(this);	var tel = $("#tel").val();	if (tel == '') {		alert("请输入手机号码");		return	}	var regu = /^[1][0-9]{10}$/;	var re = new RegExp(regu);	if (!re.test(tel)) {		alert("请输入正确手机号码");		return	}	var submitData = {		tid: 5,		code: $("#sncode").text(),		tel: tel,		action: "setTel"	};		$.post('http://127.0.0.1/index.php?ac=activityuser_sn', submitData,	function(data) {		if (data.success) {			alert("提交成功,谢谢您的参与");			$("#result").slideUp(500);			$("#outercont").slideToggle(500);			running = false;			return		} else {alert("提交失败");			$("#result").slideUp(500);			$("#outercont").slideToggle(500);		}					},	"json")				});


回复讨论(解决方案)

$post['txt_Name'] = $tel;
$tel在哪里定义的?你的框架是直接post后就可以使用该变量了么?

$post = $this->input->post(NULL, TRUE);
打印¥post的值是什么

$post['txt_Name'] = $tel;
$tel在哪里定义的?你的框架是直接post后就可以使用该变量了么?

$post = $this->input->post(NULL, TRUE);
打印¥post的值是什么



	public function _FeedBack(){$post = $this->input->post(NULL, TRUE);if(isset($post['btnSubmit'])){ $post['addtime'] = time(); $this->message->insert($post);}}


提交留言


以前是这样的 这样可以获取到值 但是想改成上面那样 就获取不到值了



提交留言

用这个



提交留言

用这个

我想结合js 才没用这个的