Im using a Codeigniter but why am I getting these error (1) Message: Undefined property: Welcome::$session (2) Message: Call to a member function flashdata() on null
Do I need to add something? Thank you
Thank you
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function index()
{
$this->load->view('home');
}
function registerNow()
{
if($_SERVER['REQUEST_METHOD']=='POST')
{
$this->form_validation->set_rules('fname', 'First Name', 'required|alpha');
$this->form_validation->set_rules('mname', 'Middle Name', 'required|alpha');
$this->form_validation->set_rules('lname', 'Last Name', 'required|alpha');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required|min_length[8]');
$this->form_validation->set_rules('confirmpass', 'Confirm Password', 'required|min_length[8]|matches[password]');
$this->form_validation->set_rules('bday', 'Birthday', 'required');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('contact', 'Contact Number', 'required|numeric');
if($this->form_validation->run()==TRUE)
{
$fname = $this->input->post('fname');
$mname = $this->input->post('mname');
$lname = $this->input->post('lname');
$username = $this->input->post('username');
$password = $this->input->post('password');
$bday = $this->input->post('bday');
$email = $this->input->post('email');
$contact = $this->input->post('contact');
$data = array(
'first_name'=>$fname,
'middle_name'=>$mname,
'last_name'=>$lname,
'username'=>$username,
'password'=>sha1($password),
'bday'=>$bday,
'email'=>$email,
'contact_number'=>$contact
);
$this->load->model('user_model');
$this->user_model->insertuser($data);
$this->session->flashdata('success','Successfully User Created');
redirect(base_url('welcome/index'));
}
}
}
}
call the session on your controller to use session
$this->load->library('session');
Or go to application\config\autoload.php
and add session to the array
$autoload['libraries'] = array('session');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.