-2
public function adduser()
{

    $this->load->model('User', 'user');
    $this->user->adduser(); 
    $data = array('message' => 'Thanks for signing up');
    $this->load->view('register', $data);
}

This is my function and it executes perfectly and gives a message of thanks to the register view page. But when I am loading the register view page initially, it gives me an error.

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: message
Filename: views/register.php
Line Number: 15

if anyone can help where it is going wrong.

Jørgen R
  • 9,997
  • 7
  • 40
  • 58

1 Answers1

0

Regard to the comment section mentioned workaround is

<?php echo ((isset($message)) ? $message : '');?>

Please see ternary operator.

Kyslik
  • 7,921
  • 5
  • 55
  • 86