I'm having a problem in PHP code. I got some code from an e-book, but when I tried to run the system, it's giving some errors. I fixed some of the errors by giving proper quotation marks, but now I'm stuck with some other errors. I want edit->apply forms with mysql
I'd be more than happy if some one helps me with the following error:
Notice: Undefined index: id in C:\xampp\htdocs\kayit_defteri\edit.php on line 17
My edit.php File
<!DOCTYPE html>
<html>
<head>
<title>Kayıt Defteri</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
</head>
<body>
<?php
include ("db.php");
$id = $_GET["id"];
$select = $db->prepare("SELECT * FROM adres WHERE id = :id");
$select->bindParam(":id", $id, PDO::PARAM_INT);
$select->execute();
$row = $select->fetch(PDO::FETCH_ASSOC);
?>
<div class="container" style="padding:20px;">
<div class="row">
<div class="col-md-12">
<h2 style="color:royalblue; font-size:28px;">Hemen Kayıt Ekleyin</h2>
</div>
</div>
<div class="row">
<div class="col-md-4">
<form method="GET" action="edit.php">
<label>İsim</label>
<input type="text" class="form-control" name ="name" value="<?php echo $row["name"];?>">
<label>Soyisim</label>
<input type="text" class="form-control" name ="surname" value="<?php echo $row["surname"];?>">
<label>Telefon</label>
<input type="number" class="form-control" name ="telephone" value="<?php echo $row["telephone"];?>">
<label>Web Sitesi</label>
<input type="text" class="form-control" name="web" value="<?php echo $row["web"];?>">
<label>Ödeyeceği Tutar</label>
<input type="text" class="form-control" name ="tutar" value="<?php echo $row["tutar"];?>">
<label>Notlar</label>
<textarea rows="2" cols="46" class="form-control" placeholder="Notunuz varsa yazın..." name="note"><?php echo $row["note"];?></textarea>
<br>
<input type="hidden" name="id" value="<?php echo $row["id"]; ?>">
<button type="submit" class="btn btn-primary">Gönder</button>
<a href="list.php"><button type="button" class="btn btn-danger">Vazgeç</button></a>
</form>
</div>
</div>
</div>
</body>
</html>
My update.php File
<?php
include ("db.php");
if($_POST) {
$name = $_POST["name"];
$surname = $_POST["surname"];
$telephone = $_POST["telephone"];
$web = $_POST["web"];
$tutar = $_POST["tutar"];
$note = $_POST["note"];
$id = $_POST["id"];
$data = array(
"name" => $name,
"surname" => $surname,
"telephone" => $telephone,
"web" => $web,
"tutar" => $tutar,
"note" => $note,
"id" => $id,
);
$update = $db->prepare("UPDATE adres SET
name=:name,
surname=:surname,
telephone=:telephone,
web=:web,
tutar=:tutar,
note=:note,
WHERE id=:id
");
$result = $update->execute($data);
if($result) {
echo "Kayıt işlemi başarılı bir şekilde gerçekleşti" . "<hr>" . "<a href='list.php'>Geri Dönün</a>";
} else {
echo "Kayıt işlemi pekte başarılı geçmedi. Tekrar deneyin.";
}
}
?>