首页 > 解决方案 > 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>';
}
?>

标签: php

解决方案


$.post("edit-check.php",{title:title,phone:phone,gheymat:gheymat,description:description,group:group,city:city}

您不会在发布请求中发送任何“agahicode”。


推荐阅读