CodeIgniter Forums
$ result does not show in view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: $ result does not show in view (/thread-41015.html)



$ result does not show in view - El Forum - 04-26-2011

[eluser]Bacu[/eluser]
I am stuck in this bug and I cannot solve it. I read already many times the user guide about form validation but I dont figure it out this problem. Please someone could help me. What I am doing wrong? I am using codeigniter 2.0.

Error: A PHP Error was encountered

Severity: Notice

Message: Undefined variable: result

Filename: views/home.php


My controller: form.php
class Form extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('signup_model');
}

public function index()
{
$data['result'] ='';

$this->load->library('form_validation');

$this->load->database();

$this->form_validation->set_rules('email', 'Email', 'required|valid_email', 'E-mail is not vhttp://ellislab.com/forums/newtopic/51/alid!');

if ($this->form_validation->run() == FALSE)
{
$data['result'] = validation_errors();
$this->load->view('home', $data);
}
else
{
$data['result'] = $this->signup_model->create();
$this->load->view('home', $data);
}
}
}

My view: home.php
<form method="post" action="form">
<p class="space">Sign-up: &lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" size="30" /&gt;
&lt;input type="hidden" name="type" value="&lt;?php echo set_value('type'); ?&gt;" size="50" /&gt;
&lt;input type="submit" class="button" value="Submit" /&gt;&lt;/p>
&lt;/form
&lt;span>&lt;?php echo $result; ?&gt;</span>


$ result does not show in view - El Forum - 04-26-2011

[eluser]toopay[/eluser]
Before you submit your code, wrap it with code tags
Code:
// Remove the space after 'code' before ']'
[code ]
// your code here
[/code ]
And if you want to ask something which didnt related with CI Bugs, please use another section!