3
I’m making a recording in the bank received from a form, it’s recording, only I want a message to appear after the recording, which was successfully received. But it’s giving the error below. I’ve been stuck in it for 2 days, I don’t know how to fix it. Or any suggested changes to the recording, for json, I’m open to suggestions.
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: alerta
Filename: public/contato.php
Line Number: 72
Backtrace:
File: D:\xampp\htdocs\alertweb\application\views\public\contato.php
Line: 72
Function: _error_handler
File: D:\xampp\htdocs\alertweb\application\views\public\index.php
Line: 7
Function: include
File: D:\xampp\htdocs\alertweb\application\controllers\Inicio.php
Line: 45
Function: view
File: D:\xampp\htdocs\alertweb\index.php
Line: 292
Function: require_once
here is the controller
public function Contato(){
$mensagem = null;
if($this->input->post('enviarContato') === 'enviarContato'){
$nome = $this->input->post('nome');
$email = $this->input->post('email');
$telefone = $this->input->post('telefone');
$assunto = $this->input->post('assunto');
$texto = $this->input->post('texto');
$this->load->model('InicioModel');
$this->InicioModel->gravarContato($nome,$email,$telefone,$assunto,$texto);
if($this->InicioModel->gravarContato === true){
$mensagem = array('class' => 'success',
'mensagem' => 'Mensagem enviada com sucesso, retornaremos em breve.'
);
}else{
$mensagem = array('class' => 'danger',
'mensagem' => 'Ocorreu um erro! Favor, tentar mais tarde.'
);
}
}
$dados = array('alerta' => $mensagem);
$this->load->view('public/index', $dados);
}
and the view
<div class="col-md-9 col-xs-9 col-lg-9 col-sm-9">
<form class="form-horizontal" action="<?php echo base_url('Inicio/contato');?>" method="post">
<fieldset>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="nome">Nome</label>
<div class="col-md-5">
<input id="nome" name="nome" type="text" placeholder="Digite o seu nome" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="email">E-mail</label>
<div class="col-md-5">
<input id="email" name="email" type="text" placeholder="Digite o seu e-mail" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="telefone">Telefone</label>
<div class="col-md-5">
<input id="telefone" name="telefone" type="text" placeholder="Digite o seu telefone" class="form-control input-md" required="">
</div>
</div>
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="assunto">Assunto</label>
<div class="col-md-5">
<input id="assunto" name="assunto" type="text" placeholder="Digite o assunto do contato" class="form-control input-md" required="">
</div>
</div>
<!-- Textarea -->
<div class="form-group">
<label class="col-md-4 control-label" for="texto"></label>
<div class="col-md-5">
<textarea class="form-control textarea" id="texto" name="texto" style="height: 200px;"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="texto"></label>
<div class="col-md-5">
<button class="btn btn-default" type="submit" name="enviarContato" value="enviarContato">Enviar <i class="fa fa-envelope-o"></i></button>
</div>
</div>
<?php if($alerta != null){?>
<div class="form-group">
<div class="col-md-12">
<div class="col-md-4"></div>
<center>
<div class="col-md-4">
<div class="alert alert-<?php echo $alerta['class'];?>">
<?php echo $alerta['mensagem'];?>
</div>
</div>
</center>
</div>
</div>
<?php }?>
</fieldset>
</form>
</div>
</div>
<?php if($alert != null){? > I don’t understand what $alert is?
– mauricio caserta