I am developing a PHP MVC Framework. But when i insert post then i can see this error. How can I solve this error? I want to validate my input fields. prevent empty fields. Here is my error screenshot
Bellow My codes
class DForm{
public $currentValue;
public $values = array();
public $errors = array();
// Mehod Post
public function post($key){
$this->values[$key] = trim(isset($_POST['$key']));
$this->$currentValue = $key;
return $this;
}
// Empty Method
public function isEmpty(){
if (empty($this->values[$this->$currentValue])) {
$this->errors[$this->$currentValue]['empty'] = "Field must not be Empty!";
}
return $this;
}
// Empty Method for Only Category
public function isCatEmpty(){
if ($this->values[$this->$currentValue] == 0) {
$this->errors[$this->$currentValue]['empty'] = "Field must not be Empty!";
}
return $this;
}
// Lenth method
public function length($min= 0, $max){
if (strlen($this->values[$this->$currentValue]) < $min OR $this->values[$this->$currentValue] > $max) {
$this->errors[$this->$currentValue]['length'] = "Should min".$min." And Max ".$max." Characters!";
}
return $this;
}
// Submit Method
public function submit(){
if (empty($this->errors)) {
return true;
}else{
return false;
}
}
}