-4

Hi I have problem with undefined index and when i submit send message for me Undefined index: agahicode in C:\wamp\www\Ehsan\user\edit-check.php on line 12 and not change in DataBase. please help me enter image description here

Notice: Undefined index: id in C:\wamp\www\member\index.php on line 17

Here is the code of 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>

and Here is the code of 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>';
}
?>
Ehsan
  • 1
  • 1

1 Answers1

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

You don't send any "agahicode" in your post request.

  • when i send agahi code in request all of the agahi's in Database changes. i want one agahi chang but when i send reques code all of the database is change – Ehsan Aug 07 '18 at 10:03