0
I’m trying to develop a php mvc system but I came across this problem in Create. The post is sending multiple data repeated do not know why this is happening.
My view create looks like this
<form id="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’s only one field because I was testing, now my way 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 was then I saw why it was wrong in the Internet, it’s multiplying the post now I do not understand why.
Truth, fixed the error, I was not connecting the model in the Create method
– Alison Paulo
If you have solved the problem mark the answer as correct :)
– Costamilam