In the update page when I click the update button this error is showing:
Warning: Undefined array key “updateId”
How to solve this? Here is the code:
<?php
include('connect.php');
//id geting from the url
$id = $_GET['updateId'] ;
$sql = "SELECT * FROM seriescurd WHERE id=$id";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_assoc($result);
// echo $row['fname'];
///show whatever the data come from the database
$f_name = $row['fname'];
$l_name = $row['lname'];
$email = $row['email'];
$mobile = $row['mobile'];
//show updated data
if (isset($_POST['update'])) {
$f_name = $_POST['f_name'];
$l_name = $_POST['l_name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$sql = "UPDATE `seriescurd` SET `fname`='$f_name',`lname`='$l_name',`email`='$email',
`mobile`='$mobile' WHERE id='$id'";
$result = mysqli_query($conn, $sql);
if ($result) {
echo "data updated";
} else {
die(mysqli_error($conn));
}
}
<div class="container my-5">
<form action="">
<div class=" form-group mb-3">
<label>First name</label>
<input type="text" class="form-control" name="f_name" autocomplete="off" value="<?php echo $f_name ?>">
</div>
<div class=" form-group mb-3">
<label>Last name</label>
<input type="text" class="form-control" name="l_name" autocomplete="off" value="<?
php echo $l_name ?>">
</div>
<div class="form-group mb-3">
<label>Email</label>
<input type="email" class="form-control" name="email" autocomplete="off" value="<?php echo $email ?>">
</div>
<div class=" form-group mb-3">
<label>mobile</label>
<input type="text" class="form-control" name="mobile" autocomplete="off"value="<?php echo $email ?>">
</div>
<button type="submit" class="btn btn-dark btn-lg" name="update">update</button>
</form>
</div>
This is the update page code in the index page:
<a href="update.php?updateId=">update</a>