1
I have the following error returning in my code
Notice: Undefined variable: errors in D: wamp www mvc application controllers login.php on line 33
This is my Controller:
class Login extends BaseController {
public function __construct() {
parent::__construct();
}
public function index() {
if (Input::exists()) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array(
'required' => true
),
'password' => array(
'required' => true
),
));
if ($validation->passed()) {
//logic code for this if
} else {
$errors = $validation->errors();
}
}
$data = [
'title' => WEB_TITLE,
'validation' => $errors
];
$this->view->display('templates/default/header', $data);
$this->view->display('login/index', $data);
$this->view->display('templates/default/footer', $data);
}
}
And this is my View:
<section class="section">
<div class="container">
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<div class="panel panel-default">
<div class="panel-body">
<h3 class="page-header">
Member login
</h3>
<form method="post">
<div class="form-group">
<input type="text" name="username" placeholder="Username or E-mail" class="form-control input-sm" autocomplete="off">
</div>
<div class="form-group">
<input type="password" name="password" placeholder="Your password" class="form-control input-sm">
</div>
<button type="submit" name="loginBtn" class="btn btn-sm btn-success btn-block">
<i class="glyphicon glyphicon-log-in"></i> Sign in
</button>
</form>
<?php
if ($data['validation']) {
echo $data['validation'][0];
}
?>
</div>
</div>
<div class="text-center">
<a href="<?=Url::url_base()?>">Back to home!</a>
</div>
</div>
</div>
</div>
</section>
Note: the error only disappears if I put one @
before my variable @$errors
Show rray, I had done it but I removed it and forgot to put it again. Thank you very much.
– Guilherme SpinXO
I’m having another different error in this same code Can you help me? I can’t find the solution:
Notice: Trying to get property of non-object in D:\wamp\www\humble\application\controllers\auth.php on line 46
– Guilherme SpinXO
@Guilhermespinxo can yes, create a new question, cm the updated code.
– rray
Pronto @rray http://answall.com/questions/128214/qual-o-motivo-trying-to-get-property-of-non-object-in
– Guilherme SpinXO