this should have been easy.... but for some reason its not working ...
Controller..
Code:
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\UserModel;
class Login extends BaseController
{
public function index()
{
return view('login');
}
public function authenticate()
{
$session = session();
$userModel = new UserModel();
$email = $this->request->getVar('email');
$password = $this->request->getVar('password');
$user = $userModel->where('user_email', $email)->first();
if(is_null($user)) {
return redirect()->back()->withInput()->with('error', 'Invalid username or password.');
}
$pwd_verify = password_verify($password, $user['user_pass']);
if(!$pwd_verify) {
return redirect()->back()->withInput()->with('error', 'Invalid username or password.');
}
$ses_data = [
'user_id' => $user['user_id'],
'user_email' => $user['user_email'],
'isLoggedIn' => TRUE
];
$session->set($ses_data);
$data = array("js_to_load"=> "hello");
//$data['js_to_load']=array("https://cdn.datatables.net/2.2.2/js/dataTables.js","https://cdn.datatables.net/2.2.2/js/dataTables.tailwindcss.js");
return view( '/dashboard', $data);
}
}
View - dashboard
Code:
<?=$this->extend("layouts/postlogin_layout")?>
<?=$this->section("content")?>
<?php echo $js_to_load; ?>
<?=$this->include('partials/usersettings');?>
<?=$this->endSection()?>
keep getting
Quote:ErrorException - Undefined variable $js_to_load
I have tried everything ..
Code:
$this->load->view('/dashboard',$data);
return view( '/dashboard', $data);
echo view('dashboard', $data);
all give the same invalid variable
if in the view i put
it print's the session...
I know i am making a very small mistake some where just dont know where ...