Welcome Guest, Not a member yet? Register   Sign In
$ 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>
#2

[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!




Theme © iAndrew 2016 - Forum software by © MyBB