CodeIgniter Forums
variable from input to view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10)
+--- Thread: variable from input to view (/showthread.php?tid=61805)



variable from input to view - Dizner - 05-19-2015

Hi guys! I am new in CodeIgniter and I have one probably simple question. I tried google it but I couldn't found right answer or I just didn't new how to usi it in my code.

So, what I want is that from prisijungus.php (this is from my native language) form_input set variable that I could use in other view file.

This is my view file prisijungus.php:
PHP Code:
<?php
    
    
echo form_open('myassets/login_validation');
    
    echo 
validation_errors();
    
    echo 
"<p>El. pa&#353tas: ";
    echo 
"<br>";
    echo 
form_input('email'$this->input->post('email'));
    echo 
"</p>";
    
    echo 
"<p>Slapta&#382odis: ";
    echo 
"<br>";
    echo 
form_password('password');
    echo 
"</p>";
    
    echo 
"<p>";
    echo 
form_submit('login_submit''Prisijungti');
    echo 
"</p>";
    
    echo 
form_close();
    
    
    
?>

In other view file I will just echo variable.

I hope you understand what I want, sorry for bad english and thanks for reply's!


RE: variable from input to view - InsiteFX - 05-19-2015

There are several ways of doing this.

1) Use a session variable.

2) CI way: Makes them global to all views.
PHP Code:
$data['your_variable'] = 'your_variable';
$this->load->vars($data); 

3) Find a good Registry Class and store them in it.


RE: variable from input to view - madaan_tushar - 05-22-2015

You can't use it like this way, you have to make that variable "GLOBAl". Please browse the net to make variable in CI.

I give a hint, that it will be done in the MY_Controller.php file,I hope you extend the CI_Controller in the core folder.