I can't updata data.Also can't fixing it error.please help me

<?php

//declaring variables
$id="";
$name="";
$fathername="";
$mothername="";
$address="";
$email="";
$district="";
$nationality="";
$birthdaycirtificateno="";
$nationalid="";
$mobilenumber="";
$religion="";
$birthday="";
$gender="";
$bloodgruop="";
$hbs="";
$hiv="";
$maleria="";
$anemia="";
$area="";

//connecting to the database
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "blood_bank";
$id =$_REQUEST['id'];

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
//information usin request id

//$id =$_REQUEST['id'];
$sql = "SELECT * FROM blood_bank_db WHERE id='$id'";
$result = $conn->query($sql);
$row = mysqli_fetch_array($result);
 
 if ($conn->query($sql) === TRUE) {		
		die("Error: Data not found..");
			}	
    $name=$_POST["name"];
	$fathername=$_POST["fathername"];
	$mothername=$_POST["mothername"];	
   	$address=$_POST["address"];
	$email=$_POST["email"];
	$district=$_POST["district"];
    $nationality=$_POST["nationality"];
	$birthdaycirtificateno=$_POST["birthdaycirtificateno"];
	$nationalid=$_POST["nationalid"];
	$mobilenumber=$_POST["mobilenumber"];
	$religion=$_POST["religion"];
	$birthday=$_POST["birthday"];
    $gender=$_POST["gender"];	
    $bloodgruop=$_POST["bloodgruop"];
	$hbs=$_POST["hbs"];
	$hiv=$_POST["hiv"];
	$maleria=$_POST["maleria"];
	$anemia=$_POST["anemia"];
	$area=$_POST["area"];
	
if(isset($_POST["update"])){	
	$name=$_POST["name"];
	$fathername=$_POST["fathername"];
	$mothername=$_POST["mothername"];	
   	$address=$_POST["address"];
	$email=$_POST["email"];
	$district=$_POST["district"];
    $nationality=$_POST["nationality"];
	$birthdaycirtificateno=$_POST["birthdaycirtificateno"];
	$nationalid=$_POST["nationalid"];
	$mobilenumber=$_POST["mobilenumber"];
	$religion=$_POST["religion"];
	$birthday=$_POST["birthday"];
    $gender=$_POST["gender"];	
    $bloodgruop=$_POST["bloodgruop"];
	$hbs=$_POST["hbs"];
	$hiv=$_POST["hiv"];
	$maleria=$_POST["maleria"];
	$anemia=$_POST["anemia"];
	$area=$_POST["area"];

	$sql="UPDATE blood_bank_db SET name ='$name', fathername ='$fathername',mothername ='$mothername',address ='$address',
	      email ='$email',district ='$district',nationality ='$nationality',birthdaycirtificateno ='$birthdaycirtificateno',
		  nationalid ='$nationalid',mobilenumber='$mobilenumber',religion='$religion',birthday='$birthday',  gender='$gender',
		  bloodgruop='$bloodgruop',hbs='$hbs',hiv='$hiv',maleria='$maleria',anemia='$anemia',area='$area' WHERE id = '$id'";
		 
	$result = $conn->query($sql);
	//$result->execute();		
	echo "Saved!";
	
	header("Location: bloodbanklist.php");			

}
$conn->close();

?>


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
 
<div class="container"> 
<div class="row">
<div class="col-sm-10">
  <div class="panel panel-info">
  <div class="panel-heading"><h2>Update Information</h2></div>
  <div class="panel-body"> 
  
  <form class="form-horizontal" method="post" action="update.php">
  
  <div class="form-group">  
    <label class="control-label col-sm-2" for="Name">Name:</label>
    <div class="col-sm-8">
      <input type="text" class="form-control" name="name" placeholder="Enter Your Name" required value="<?php if(isset($name)) { echo $name; } ?>"/>
    </div>
  </div> 
  <div class="form-group">
    <label class="control-label col-sm-2" for="fathername">Father Name:</label>
    <div class="col-sm-8"> 
      <input type="text" class="form-control" name="fathername" placeholder="Enter Your Father Name" value="<?php if(isset($fathername)) { echo $fathername; } ?>"/>
    </div>
  </div>  
  <div class="form-group">
    <label class="control-label col-sm-2" for="mothername">Mother Name:</label>
    <div class="col-sm-8">
      <input type="text" class="form-control" name="mothername" placeholder="Enter Your Mother Name" value="<?php if(isset($mothername)) { echo $mothername; } ?>"/>
    </div>
  </div>  
  <div class="form-group">
    <label class="control-label col-sm-2" for="address">Address:</label>
    <div class="col-sm-8"> 
      <input type="text" class="form-control" name="address" placeholder="Enter Your Address" required value="<?php if(isset($address)) { echo $address; } ?>"/>
    </div>
  </div>  
  <div class="form-group">
    <label class="control-label col-sm-2" for="email">Email:</label>
    <div class="col-sm-8">
      <input type="email" class="form-control" name="email" placeholder="Enter Your Email Address" value="<?php if(isset($email)) { echo $email; } ?>"/>
    </div>
  </div>  
  <div class="form-group">
    <label class="control-label col-sm-2" for="district">District Name:</label>
    <div class="col-sm-8"> 
      <input type="text" class="form-control" name="district" placeholder="Enter Your District Name" required value="<?php if(isset($district)) { echo $district; } ?>"/>
    </div>
  </div> 
  <div class="form-group">
    <label class="control-label col-sm-2" for="nationality">Nationality:</label>
    <div class="col-sm-8"> 
      <input type="text" class="form-control" name="nationality" placeholder="Enter Your Country Name" value="<?php if(isset($nationality)) { echo $nationality; } ?>"/>
    </div>
  </div> 
  <div class="form-group">
    <label class="control-label col-sm-2" for="birthdaycirtificateno">Birthday Certificate No.:</label>
    <div class="col-sm-8">
      <input type="text" class="form-control" name="birthdaycirtificateno" placeholder="Enter Your Birthday Cirtificate No." value="<?php if(isset($birthdaycirtificateno)) { echo $birthdaycirtificateno; } ?>"/>
    </div>
  </div> 
  <div class="form-group">
    <label class="control-label col-sm-2" for="nationalid">National ID:</label>
    <div class="col-sm-8"> 
      <input type="text" class="form-control" name="nationalid" placeholder="Enter Your National ID" value="<?php if(isset($nationalid)) { echo $nationalid; } ?>"/>
    </div>
  </div>   
  <div class="form-group">
    <label class="control-label col-sm-2" for="mobilenumber">Mobile Number:</label>
    <div class="col-sm-8">
      <input type="text" class="form-control" name="mobilenumber" placeholder="Enter Your Mobile Number" value="<?php if(isset($mobilenumber)) { echo $mobilenumber; } ?>">
    </div>
  </div> 
 <div class="form-group">
  <label class="control-label col-sm-2" for="religion">Religion:</label>
  <div class="col-sm-8"> 
  <select name="religion" value="<?php if(isset($religion)) { echo $religion; } ?>"/>
    <option value="select">Select</option>
    <option value="muslim">Muslim</option>
    <option value="hindu">Hindu</option>
    <option value="chiristian">Chirstian</option>
    <option value="buddha">Buddha</option>
	<option value="others">Others</option>
  </select>
  </div>
</div> 

<div class="form-group">
 <label class="control-label col-sm-2" for="birthday">Birthday:</label>
  <div class="col-sm-8">
  <input type="date" class="form-control" name="birthday" placeholder="Enter Your Birthday Date" value="<?php if(isset($birthday)) { echo $birthday; } ?>"/>
</div></div>
  
  <div class="form-group">
  <label class="control-label col-sm-2" for="gender" value="<?php if(isset($gender)) { echo $gender; } ?>"/>Gender</label>
  <div class="col-sm-8">
  <input type="radio" name="gender" value="male" checked>Male
  <input type="radio" name="gender" value="female" >Female
  <input type="radio" name="gender" value="others" disabled>Others
  </div>
  </div> 
  <div class="form-group">
  <label class="control-label col-sm-2" for="bloodgruop">Blood Group:</label>
  <div class="col-sm-8"> 
  <select name="bloodgruop">
    <option value="select" value="<?php if(isset($bloodgruop)) { echo $bloodgruop; } ?>">Select</option>
    <option value="A+">A+</option>
    <option value="A-">A-</option>
    <option value="AB+">AB+</option>
    <option value="AB-">AB-</option>
	<option value="B+">B+</option>
    <option value="B-">B-</option>
    <option value="O+">O+</option>
    <option value="O-">O-</option>
  </select>
  </div>
</div>   
   <div class="form-group">
  <label class="control-label col-sm-2" for="hbs">Has any HBS+:</label>
  <div class="col-sm-8">
  <input type="radio" name="hbs" value="yes" checked value="<?php if(isset($hbs)) { echo $hbs; } ?>"/>Yes
  <input type="radio" name="hbs" value="no" value="<?php if(isset($hbs)) { echo $hbs; } ?>"/> No
  </div>
  </div>  
  <div class="form-group">
  <label class="control-label col-sm-2" for="hiv">Has any HIV+:</label>
  <div class="col-sm-8">
  <input type="radio" name="hiv" value="yes" checked value="<?php if(isset($hiv)) { echo $hiv; } ?>"/>Yes
  <input type="radio" name="hiv" value="no" value="<?php if(isset($hiv)) { echo $hiv; } ?>"/> No
  </div>
  </div> 
  <div class="form-group">
  <label class="control-label col-sm-2" for="maleria">Has any Maleria:</label>
  <div class="col-sm-8">
  <input type="radio" name="maleria" value="yes" checked value="<?php if(isset($maleria)) { echo $maleria; } ?>"/>Yes
  <input type="radio" name="maleria" value="no" value="<?php if(isset($maleria)) { echo $maleria; } ?>"/> No
  </div>
  </div> 
  <div class="form-group">
  <label class="control-label col-sm-2" for="anemia">Has any Anemia:</label>
  <div class="col-sm-8">
  <input type="radio" name="anemia" value="yes" checked value="<?php if(isset($anemia)) { echo $anemia; } ?>"/>Yes
  <input type="radio" name="anemia" value="no" value="<?php if(isset($anemia)) { echo $anemia; } ?>"/> No
  </div>
  </div> 
   <div class="form-group">
  <label class="control-label col-sm-2" for="area">Area You Want To Donate:</label>
  <div class="col-sm-8"> 
  <select name="area" value="<?php if(isset($area)) { echo $area; } ?>"/>
    <option value="select">Select</option>
    <option value="anywhere">Any Where</option>
    <option value="insidegognogor">Inside Gognogor UP</option>
    <option value="insidenarayangonj">Inside Narayangonj</option>
	<option value="alltheplacesinside dhaka">All The Places Inside Dhaka</option>
  </select>
  </div>
</div> 
  <div class="form-group"> 
    <div class="col-sm-offset-2 col-sm-10">
      <button type="submit" name="update" class="btn btn-success">Update</button>
	   <a class="btn btn-info"href="bloodbanklist.php">Back</a>
	  <button type="reset" class="btn btn-primary">Reset</button>
    </div>
  </div>
  </form>

</div>
</div>
</div>
</div>
</div>
</body>
</html>

What is the error? How far through your PHP code does it get? Why do you assign all the variables twice? Are you sure all the column names are spelled the same as they are in your table definition?

Where does the value of $id come from? I can’t see that anywhere in your form code.

Off Topic

When you post code here, @jewelrana449, you need to format it so that it will display correctly.

You can highlight your code, then use the </> button in the editor window, which will format it, or you can place three backticks ``` (top left key on US/UK keyboards) on a line before your code, and three on a line after your code. I find this approach easier, but unfortunately some European and other keyboards don’t have that character.

I thought I posted a more secure snippet, but I guess OP would rather want their website hacked.

https://www.sitepoint.com/community/t/cant-solving-this-error/240691/22?u=spaceshiptrooper

I am not experienced with PHP but based on my experience with other languages it looks to me that you are not checking for an error from the query. That is the type of thing that often results in the type of problem you have.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.