successfully updated but with an error
<br /><b>Warning</b>: Undefined variable $topic in <b>C:\xampp\htdocs\mintech\templates\editcat.php</b> on line <b>13</b><br /><br /><b>Warning</b>: Attempt to read property
Warning: Undefined array key "cat_id" in C:\xampp\htdocs\mintech\editcat.php on line 10
Am sorry am new to php oop mvc structures I tried passing the id into the action=editcat.php not i also tried input hidden to pass the cat_id still nothing i tried declaring a variable topic nothing i tried changing the placeholder when updating nothing
public function update_Cat($data){
//Insert Query
$this->db->query("UPDATE `categories` SET name=:name Where cat_id = :cat_id ");
//Bind Values
$this->db->bind(':name', $data['name']);
$this->db->bind(':cat_id', $data['cat_id']);
if($this->db->execute()){
return true;
} else {
return false;
}
//echo $this->db->lastInsertid
}
<?php
//Create Topics Object
$topic = new Topic;
$user = new User;
$validate = new Validator;
//Get Template From URL
$categories_id = $_GET['cat_id'];
if (isset($_POST['edit_cat'])) {
//Creatr Data array
$data = array();
$data['name'] = $_POST['name'];
//required array
$field_array = array('name');
if ($validate->isRequired($field_array)) {
//Register User
if ($topic->update_Cat($data)) {
redirect('editcat.php', 'your Category has been updated', 'success');
} else {
redirect('editcat.php', 'Something went wrong with your Update', 'error');
}
} else {
redirect('editcat.php', 'Name field is required', 'error');
}
}
it seems when i was passing the id it was not been passed through so instead i changed the method of passing the id in the form and also added input hidden and passed the id and declared it on the editcat.php then it worked wow thanks team
you really opened my mind