Welcome Guest, Not a member yet? Register   Sign In
help please! i can't pass the data to views
#1

[eluser]dadamssg87[/eluser]
Hi,

I'm trying to go through the tutorial and i can not pass the $data variables to views. I have no idea whats going on. I am using MAMP.

here is my controller
Code:
<?php

class Register extends Controller {

    function Register()
    {
        parent::Controller();
        $this->load->helper('form');
        $this->load->library('session');    
    }
    
    function index()
    {
        $data['title'] = "Register!";
        
        $this->load->view('header_view', $data);
        $this->load->view('register_form');
        $this->load->view('footer_view');
    }
}

?>

and here is my view
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

&lt;html &gt;
&lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;

    &lt;title&gt;&lt;?=$title?&gt;&lt;/title&gt;
    
&lt;/head&gt;
&lt;body&gt;

and i'm getting this error
Quote:<h4>A PHP Error was encountered</h4>

<p>Severity: Notice</p>
<p>Message: Undefined variable: title</p>
<p>Filename: views/header_view.php</p>
<p>Line Number: 8</p>

any help would be MUCH appreciated! Thanks in advance!
#2

[eluser]dudeami0[/eluser]
Code:
function index()
    {
        $data = Array();
        $data['title'] = "Register!";
        
        $this->load->view('header_view', $data);
        $this->load->view('register_form');
        $this->load->view('footer_view');
    }

That might fix your problem :p Not 100% sure, but its worth a shot.
#3

[eluser]InsiteFX[/eluser]
Code:
function index()
    {
        $data['title'] = "Register!";
        
        $this->load_vars($data);

        $this->load->view('header_view');
        $this->load->view('register_form');
        $this->load->view('footer_view');
    }

Make sure also that short tags are turned on!

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB