I'm trying to develop a php mvc system but I came across this problem in Create. The post is sending multiple repeated data I do not know why this is happening.
Myviewcreateislikethis
<formid="form1" action="<?php echo BASE_URL; ?>Products/Create" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Nome</label>
<input type="text" value="" class="form-control" name="name" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<button type="submit" class="btn btn-success">Cadastrar</button><br><br>
</form>
There is only one field because I was testing, now my method in the controller
public function Create(){
$this->view->title = 'Novo';
$this->view->dados = $_POST;
if($_POST){
//$this->view->errors = 'Não é um número';
var_dump($_POST);
$result = $this->Create($_POST['name']);
if($result == true){
$this->Redirect('Index');
}
$this->view->Render('Create');
exit;
}
var_dump($_POST['name']);
//$this->view->dados = $_POST;
$this->view->Render('Create');
}
I put the var_dump it was there that I saw why it gave error in the insert, it is multiplying the post now I do not understand why.