• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$ result does not show in view

#1
[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>


Messages In This Thread
$ result does not show in view - by El Forum - 04-26-2011, 01:38 AM
$ result does not show in view - by El Forum - 04-26-2011, 01:53 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.