I made a function in class connectDB
to update a document then try to call that function and always has error :
Notice: Undefined index: username in C:\xampp\htdocs\phpmongodb\TM\connectDB.php on line 34
Notice: Undefined index: name in C:\xampp\htdocs\phpmongodb\TM\connectDB.php on line 35
Notice: Undefined index: email in C:\xampp\htdocs\phpmongodb\TM\connectDB.php on line 36
public function editAdmin( $editInfo = [])
{
$edited = $this->db->updateOne(
['_id'=>$editInfo['_id']],
['$set' =>['username' =>$editInfo['username'],
'name'=>$editInfo['name'],
'email'=>$editInfo['email'] ]],
['multi' => false, 'upsert' => false]
);
return $edited;
}
and this is how I use the function in anothe php page will inputs:
$edited=$db->editAdmin(
['_id'=>new MongoDB\BSON\ObjectID($id)],
['$set' =>
['username' =>$_POST['U'],
'name'=>$_POST['N'],
'email'=>$_POST['E']]
],
['multi' => false, 'upsert' => false]
);
print_r($edited->getModifiedCount());
print_r($edited->getMatchedCount());
<input type='text' name='U' id='U' class='form-control' placeholder='Username' >
<input type='text' name='N' id='N' class='form-control' placeholder='Name' >
<input type='text' name='E' id='E' class='form-control' placeholder='E_mail'>
all other CRUD operation works well except 'update' and I still don't know why it doesn't take what I write in $_POST.
Can anyone help please?