Kishan Kumar

Kishan Kumar

  • 1.8k
  • 127
  • 6.7k

update data in php with condition

Mar 28 2018 1:46 AM
I make a registration page.
So Registration page ready and fetch data with page view data.
so update option not working some errors....
attach all file zip folder with database...
Error showing this 
Notice: Undefined variable: conn in C:\xampp\htdocs\registration\update.php on line 25

Fatal error: Call to a member function query() on null in C:\xampp\htdocs\registration\update.php on line 25 
Please resolve.......or new code comment....
Thanks so much.... 
exit('User Not Exists.');
$mysqli = new mysqli("localhost", "root", "", "test");
// Check connection
if($mysqli === false){
die("ERROR: Could not connect. " . $mysqli->connect_error);
// Attempt select query execution
$sql = "SELECT * FROM record where id = ".$_GET['id'];
if($result = $mysqli->query($sql)){
if($result->num_rows > 0){
$row = $result->fetch_array();
$sql = "UPDATE record SET name='".$_POST['name']."', email='".$_POST['email']."', mobile='".$_POST['mobileno']."', address='".$_POST['address']."' WHERE id=".$_GET['id'];
if ($conn->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $conn->error;
<div id="page-wrapper">
<!----Add Student Start---->
<form action="" method="post">
<div class="container">
<p> Name:-<span style="color:red;">*</span><input type="text" name="name" value="<?=$row['name'];?>" placeholder=" name" id=""/></p>
<p>Email<span style="color:red;">*</span><input type="text" name="email" value="<?=$row['email'];?>" id=""/></p></br>
<p>Address<span style="color:red;">*</span><input type="text" name="address" id="" value="<?=$row['address'];?>" /></p></br>
<p>Mobile No<span style="color:red;">*</span><input type="text" name="mobileno" id="" value="<?=$row['mobileno'];?>" /></p></br>
<input type="submit" name="update" value="update" id=""/></p></br>


Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (1)