I am new in php and as well in database. I am facing issue to update table in database. i am getting values in input field but when i update query is not working.
$edit_id=$_GET['edit_id'];
$get_data = mysqli_query($con, "SELECT * FROM userform WHERE id='$edit_id' ");
$run = mysqli_fetch_array($get_data);
if (!$run) {
echo "something went wrong";
}
else{
echo "Working Fine";
}
if(isset($_POST['update'])){
$name = $_POST['name'];
$email = $_POST['email'];
$subjects = $_POST['subjects'];
$phone = $_POST['phone'];
$country = $_POST['country'];
$city = $_POST['city'];
$address = $_POST['address'];
$position = $_POST['position'];
$about = $_POST['about'];
$query = mysqli_query($con, "UPDATE userform SET name='$name', email='$email', subjects='$subjects', phone='$phone', country='$country', city='$city', address='$address', position='$position', about='$about', WHERE id='$edit_id' ");
//$run = mysqli_query($query);
if ($query) {
echo "<script>alert('User Date Inserted Successfully'); </script>";
//header('location:records.php');
}
else{
echo "<br> Something went wrong";
}
exit();
}
?>
<div id="outer">
<form method="POST" enctype="multipart/form-data">
<input type="text" name="name" value="<?php echo $run['name']; ?>" >
<input type="email" name="email" value="<?php echo $run['email']; ?>" >
<input type="text" name="subjects" value="<?php echo $run['subjects']; ?>" >
<input type="text" name="phone" value="<?php echo $run['phone']; ?>" >
<input type="text" name="country" value="<?php echo $run['country']; ?>" >
<input type="text" name="city" value="<?php echo $run['city'] ?>" >
<input type="text" name="address" value="<?php echo $run['address']; ?>" >
<input type="text" name="position" value="<?php echo $run['position']; ?>" >
<textarea name="about" value="<?php echo $run['about']; ?>" ></textarea>
<input id="sbmt" type="submit" value="Update Value" name="update">
</form>
</div>