CodeIgniter Forums
CI3 die(var_dump($_POST)) is showing input value in the controller but - 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: CI3 die(var_dump($_POST)) is showing input value in the controller but (/showthread.php?tid=76301)



CI3 die(var_dump($_POST)) is showing input value in the controller but - P1207 - 05-01-2020

On submitting the values through the form, the controller is receiving the submitted values as checked by using 'die(var_dump($_POST));'
but otherwise control move to  ($this->form_validation->run() == FALSE) and nothing happened.
 I have tried every possible option but I am unable to find any solution. Anything else needed?

//my controller is

Class User_authentication extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('login_db');
}

public function index() {
$this->load->view('login_form');
}


public function user_login_process()
{
//die(var_dump($_POST)); //giving posted value

//echo $this->input->post('emailid'); //giving nothing
//echo $this->input->post('password'); //giving nothing

$this->form_validation->set_rules('emailid','Email','required');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]|max_length[8]');
$pass=base64_encode($this->input->post('password'));

if ($this->form_validation->run() == FALSE)
{
$this->load->view('login_form');
}
else
{
$data = array(
'user_email' => $this->input->post('emailid'),
'user_password' => $pass
);

$result = $this->login_db->login($data);
$this->session->set_userdata('logged_in', $session_data);

}


//my view login_form.php


<div id="submain">
<h2>Login Form</h2>
<hr>
<?php if(isset($error_message)){?>
        <div class="error_msg">
            <?php echo $error_message; ?>
        </div>
    <?php }

  echo form_open('user_authentication/user_login_process');
echo validation_errors();
?>
<label>Login Id :</label>
<input type="email" name="emailid" id="emailid" placeholder="[email protected]"><br>
<?php echo form_error('emailid', '<div class="error_msg">',
'</div>'); ?>
<br>
<label>Password :</label>
<input type="password" name="password" id="password" placeholder="****"><br>
<?php echo form_error('password', '<div class="error_msg">',
'</div>'); ?><br>

<input type="submit" value="Login" name="submit" id="submit"><br>
<?php echo form_close(); ?>
<a href="user_registration_show" style="color:darkblue;font-size:20px;">To SignUp Click Here</a>
</div>


//config.php setup is 
$config['base_url'] ='http://localhost:85/Airline/';
$config['index_page'] = 'index.php';


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - php_rocs - 05-01-2020

@P1207,

It doesn't look like you loaded the form_validation library ( https://codeigniter.com/userguide3/tutorial/create_news_items.html#create-a-form ).


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - P1207 - 05-01-2020

Hi!
I have loaded it in autoload.php

$autoload['libraries'] = array('form_validation','database','session');


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - php_rocs - 05-02-2020

@P1207,

...and is your url and form helpers auto loaded as well?


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - P1207 - 05-02-2020

Yes
$autoload['helper'] = array('form','url','html','file','date','string','security');


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - php_rocs - 05-02-2020

@P1207,

Have you determined what the actual value of $this->form_validation->run() is prior to the if condition?


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - P1207 - 05-02-2020

(05-02-2020, 11:48 AM)php_rocs Wrote: @P1207,

Have you determined what the actual value of $this->form_validation->run() is prior to the if condition?
Yes it is giving bool(false) on var_dump($this->form_validation->run());
and my code is behaving very abnormally. Like when I am providing the value in the form which is stored in the database, the form get reloaded and comes to the end of the code. But.... when the values are not from db but in the proper format, it is doing all checking and providing invalid login id. 

I am attaching a file with code n screens with messages


RE: CI3 die(var_dump($_POST)) is showing input value in the controller but - P1207 - 05-03-2020

Hi found the problem!
it is with session. when I commented the entire part for saving session data, program works fine.
But now how could I handle the session?