1

I have this function in ** controller **

function smsreq() { $this->form_validation->set_rules('amount', 'Amount', 'trim|required|xss_clean'); $this->form_validation->set_rules('mobileNo', 'Mobile Number', 'trim|required|xss_clean'); if ($this->form_validation->run()) { echo "validated"; } else { $data = "<div>TEST</div>" ; $this->load->view('dashboard',$data); } } 

and in the ** view **

<?php echo $data ; ?> 

But when the view,'dashboard' is loaded this is shown

A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: views/dashboard.php Line Number: 190 

Why cant I pass the value?

1 Answer 1

1

you have to pass as array from controller to view.

$data["data"] = "<div>TEST</div>" ; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.