I want to update my record in database and showing in table but this code i cant understand what problem happen. kindly inform me thanks. i am very thankful to you my dear. how can i correct it?? how it is possible and what problem occur in this code
<?php
include("connection.php");
$edit_rec = $_GET['edit'];
$query= "SELECT * from card_rec where id='$edit_rec'";
$run = mysqli_query($con,$query);
$row = mysqli_fetch_row($run);
if ($_POST)
{
$name = $_POST['name'];
$fname = $_POST['fname'];
$school = $_POST['school'];
$address = $_POST['address'];
$contact = $_POST['contact'];
$id = $_POST['id'];
$query1="UPDATE card_rec SET name='$name', fname='$fname', school='$school',address='$address',contact= '$contact' WHERE id='$id'";
if ($query1) {
echo "<script>alert('Record Update'); window.location = 'card_rec.php' </script>";
}
else
{
echo "not update";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Update</title>
</head>
<body>
<form method="post">
<input type="hidden" name="id" value="<?php echo $row[0] ?>"><br>
<input type="text" name="name" value="<?php echo $row[1] ?>"><br>
<input type="text" name="fname" value="<?php echo $row[2] ?>"><br>
<input type="text" name="school" value="<?php echo $row[3] ?>"><br>
<input type="text" name="address" value="<?php echo $row[4] ?>"><br>
<input type="text" name="contact" value="<?php echo $row[5] ?>"><br>
<input type="submit" name=" submit">
</form>
</body>
</html>