php - PHP:未定义索引:agahicode
问题描述
嗨,我有未定义索引的问题,当我为我提交发送消息时未定义索引:第 12 行 C:\wamp\www\Ehsan\user\edit-check.php 中的 agahicode 并且在数据库中没有更改。请帮我 在这里输入图片描述
Notice: Undefined index: id in C:\wamp\www\member\index.php on line 17
这是Edit.php的代码
<?php
include '../connect.php';
$sql="select * from agahi where code = ?";
$result=$connect->prepare($sql);
$result->bindValue(1,$_GET["agahicode"]);
$result->execute();
$tedad=$result->rowCount();
$data=$result->fetch(PDO::FETCH_OBJ) ;
?>
<script>
$(document).ready(function(e) {
$("#group").val(<?= $data->group ?>);
$("#city").val(<?= $data->city ?>);
$("#register").click(function(){
var title = $("#title").val();
var phone = $("#phone").val();
var gheymat = $("#gheymat").val();
var description = $("#description").val();
var group = $("#group").val();
var city = $("#city").val();
$.post("edit-check.php",{title:title,phone:phone,gheymat:gheymat,description:description,group:group,city:city},function(data){
$("#msg").html(data);
});
});
});
</script>
这是edit-check.php的代码
<?php
session_start();
include '../connect.php';
$sql="UPDATE `golestan`.`agahi` SET `title` = ?, `phone` = ?, `gheymat` = ?, `description` = ?, `group` = ?, `city` = ? WHERE `code` = ?;";
$result=$connect->prepare($sql);
$result->bindValue(1,$_POST["title"]);
$result->bindValue(2,$_POST["phone"]);
$result->bindValue(3,$_POST["gheymat"]);
$result->bindValue(4,$_POST["description"]);
$result->bindValue(5,$_POST["group"]);
$result->bindValue(6,$_POST["city"]);
$result->bindValue(7,$_POST["agahicode"]);
if($result->execute())
{
echo '<span style="color:green">ok</span>';
}
else
{
echo '<span style="color:red;">error</span>';
}
?>
解决方案
$.post("edit-check.php",{title:title,phone:phone,gheymat:gheymat,description:description,group:group,city:city}
您不会在发布请求中发送任何“agahicode”。
推荐阅读
- python - 即使我明确为它分配了不同的值,方法属性也不会自行更新
- javascript - 如何使 html 运行没有开始或结束的代码?
- javascript - JS在生成的ajax div中添加文本
- flutter - Flutter 图像选择器已经激活,null 异常
- go - 在 Go 中使用 stdlib 中未导出的函数/类型
- performance - CSV 迄今为止和浮动
- c++ - 使用 old_pointer + offset 的 new_pointer 设置 shared_ptr
- vb.net - txtBoxes 列表 - System.NullReferenceException:
- python - 如何创建一个包含文件中每一行的第一个单词的列表(Python 3)
- dji-sdk - DJI Windows SDK 示例 - 无法查看 FPV 模式