there is a function in the controller
function action_add() { if(isset($_POST['submit'])){ $title = $_POST['title']; $description = $_POST['description']; if(empty($title)) { $error = 'Please enter the title'; } if(empty($description)) { $error = 'Please enter the desc'; } if(!isset($error)){ $data = array( 'title' => $title, 'description' => $description ); $this->model->add_data($data); } } $this->view->generate('main/add_view.php','template_view.php'); }
Here is the form in the view
<form class="main_form" method="post""> <label class="form-group"> <span class="color_element">*</span> Заголовок: <input type="text" name="title" placeholder="Ваш заголовок" data-validation-required-message="Вы не ввели заголовок" required /> </label> <label class="form-group"> <span class="color_element">*</span> Текст Вашей новости: <textarea name="description" placeholder="text text text" data-validation-required-message="Вы не ввели основную часть новости" required></textarea> </label> <input type='submit' name="submit" value='Добавить' class="button"> </form>
and model
public function add_data($data) { $query = mysql_query("INSERT INTO news VALUES ('".$data['title']."', '".$data['description'].")"); }
There are no errors and notifications, but the data is not entered, please indicate errors and omissions, thanks in advance