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

  • Why is the form not specified action? And an extra quotation mark at the end. Data from the form exactly go to the page you require? What is the framework used? Have you checked that the action_add method is generally called when the form is submitted? - Alexander Soloshenko
  • for completely forgot about it .. and how, then, in the action to specify the method action_add? no, they don’t make it, my mini frame framework, so now I’m doing a bicycle, but it is called when sending - Alexandr
  • In the query, you are missing one closing single quote after $ data ['description']. Do you have error output disabled? - Alexander Soloshenko

1 answer 1

It is necessary to add action

  <form class="main_form" method="post"" action =""> 
  • yes it is a joint, but the problem is probably not only in this .. even after adding nothing has changed - Alexandr