php大神进。为什么我的页面不能正常post数据
<formmothod="post"><inputtype="text"name="id"value="2"><inputtype="text"name="datetim...
<form mothod="post">
<input type="text" name="id" value="2">
<input type="text" name="datetime" value="2014-5-22 15:42">
<input type="submit" value="提交">
</form>
<?php
$link=mysql_connect("localhost","root","110");
if(!$link){
die("<h1>failed!</h1>");
}
mysql_query("SET NAMES utf8");
mysql_select_db("test",$link);
$sql=mysql_query("select * from date_time",$link);
$response = array();
if(isset($_POST['id'])&&isset($_POST['datetime'])){
$id = $_POST['id'];
$datetime = $_POST['datetime'];
$result = mysql_query("insert into date_time(id,datetime) values ('$id','$datetime')");
if($result){
$response["status"] = 200;
$response["message"] = "upload success!";
}else{
$response["status"] = 100;
$response["message"] = "oops!upload failed!";
}
}else{
$response["status"] = 300;
$response["message"] = "required fields is missing";
}
print(json_encode($response));
mysql_close();
?> 展开
<input type="text" name="id" value="2">
<input type="text" name="datetime" value="2014-5-22 15:42">
<input type="submit" value="提交">
</form>
<?php
$link=mysql_connect("localhost","root","110");
if(!$link){
die("<h1>failed!</h1>");
}
mysql_query("SET NAMES utf8");
mysql_select_db("test",$link);
$sql=mysql_query("select * from date_time",$link);
$response = array();
if(isset($_POST['id'])&&isset($_POST['datetime'])){
$id = $_POST['id'];
$datetime = $_POST['datetime'];
$result = mysql_query("insert into date_time(id,datetime) values ('$id','$datetime')");
if($result){
$response["status"] = 200;
$response["message"] = "upload success!";
}else{
$response["status"] = 100;
$response["message"] = "oops!upload failed!";
}
}else{
$response["status"] = 300;
$response["message"] = "required fields is missing";
}
print(json_encode($response));
mysql_close();
?> 展开
2个回答
展开全部
你先打印$_POST数组,在打印你的sql,自然知道哪里出问题了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询