How to make controller print two different things in my html at different part |
[eluser]adityajoshi[/eluser]
thanks , you are one of my angel, last time you helped me so much. i will try to work using sessiontomorrow,also i have some issue with login. My login has different codeigniter folder and form has different ci folder, in my login i am redirecting to my form but when i use the dump variable its shows empty array.form and login has different controller and views i wonder where variables are lost
[eluser]adityajoshi[/eluser]
I think in my post it was my mistake, i learn php recently,i think we can not pass the data to another page until its a form data. but thanks for the guidance
[eluser]adityajoshi[/eluser]
I am having problem how to use the value of var_dump from login page in the controller My login page passes the following variable to controller but i am not still able to use it when i try to use inside the controller my controller is <?php $result = $_POST['username']; var_dump($_POST); class Login extends Controller { public function __construct() { parent::Controller(); $this->load->helper(array('form','url')); $this->load->library('form_validation'); $this->load->library('session'); } public function index() { $this->load->view('/'); } public function submit() { if ($this->_submit_validate() === FALSE) { $this->session->set_userdata(array('userid'=>$result)); $sess = $this->session->userdata('userid'); echo $sess; $this->index(); return; } $this->session->set_userdata(array('userid'=>$result)); redirect('http://localhost/calendar/add'); } i am getting error A PHP Error was encountered Severity: Notice Message: Undefined variable: result Filename: controllers/login.php Line Number: 24 even if i try to just mere echo $result in side my controller it doesn't recognise it Any help will be highly appreciated
[eluser]CodeIgniteMe[/eluser]
use <code> $result = $_POST['some_element']; ... global $result; </code> but why don't you want to declare $result as a property in your controller?like this <code> Class Mycontroller extends CI_Controller{ public $result = $_POST['whatever']; function somefunction(){ $this->session->set_userdata(array('key'=>$this->result)); } } </code> if you want to always var_dump() on $result, you can always do it inside a function or the constructor: <code> function __construct(){ parent::__construct(); var_dump($this->result); } </code>
[eluser]adityajoshi[/eluser]
Code: I am still having problem
[eluser]CodeIgniteMe[/eluser]
You have incorrect usage in your codes. But we will try to fix that. 1. If you plan to use $this->var, then you should (although sometimes not required) declare it as a Class property Code: Class MyController extends Controller // because It seems that you are using CI < 2.0 2. the session did not return any value because you have set the 'userid' session to an implicitly declared variable $this->var * Doing this without doing the 1st step, will dynamically add a new class-wide variable but without any value (because it was used just after it was declared)
[eluser]adityajoshi[/eluser]
brother one more help i need from you, In local host every thing works but when i try to upload my administrator (codeigniter) folder in my hosting it is not able to find the page http://whiteroseart.com/ My code igniter folder is storied in administrator folder http://whiteroseart.com/administrator/ when i load this page it works http://whiteroseart.com/administrator/ but i click submit the page is suppose to redirect to http://whiteroseart.com/administrator/bl...ent_insert it is not able to find the page Code: <IfModule mod_rewrite.c>
[eluser]CodeIgniteMe[/eluser]
Check your server if it supports mod_rewrite. You can check by uploading a simple php page with the following codes: <?php phpinfo(); ?> then find the word "rewrite" and should be under the apache enabled modules. |
Welcome Guest, Not a member yet? Register Sign In |