• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$this->input->post not working?

#1
[eluser]bill19[/eluser]
Hi there,

I've got the following form :

Code:
<form action="http://localhost/ionauth1/index.php/auth/login" method="post" accept-charset="utf-8">    
      <p>
       <label for="identity">Email/Username:</label>

       &lt;input type="text" name="" value=""  /&gt;      </p>
      
      <p>
       <label for="password">Password:</label>
       &lt;input type="text" name="" value=""  /&gt;      </p>
      
    
      <p>&lt;input type="submit" name="submit" value="Login"  /&gt;&lt;/p>

      
    &lt;/form&gt;

and the following is my controller:

Code:
function login() {

        if($_POST) {   //clean public facing app input

            $identity = $this->input->post('identity', true);
            $password = $this->input->post('password', true);
            
            var_dump($identity);
            
          

            //Ion_Auth Login fun
            if($this->ion_auth->login($identity,$password)) {

                //capture the user
               $user = $this->ion_auth->user()->row();

                redirect($user->group.'/home');

               /*redirect to the proper home
                 controller using the user
                 groups as folder names */
            }
            else {

                // set error flashdata
                $this->session->set_flashdata(
                    'error',
                    'Your login attempt failed.'
                );

                redirect('/views/login_form');
            }
        }
        else{  // NO FORM SUBMISSION YET
        
            $data=array();
           $data['identity']='';
            $data['password']='';
            $data['message']='';

            $this->load->view('auth/login',$data);
            
        }
    }

I am trying to use the ion auth library. After the initial form submission, i try to var_dump($identity) , but I am not getting any output. Am i doing something wrong?

Thanks, in advance,

Bill

#2
[eluser]CroNiX[/eluser]
Because you tell it to redirect so you won't see it. Try putting a die() after your var_dump() so it won't continue and redirect.

#3
[eluser]bill19[/eluser]
I've changed it to:

Code:
if($_POST) {   //clean public facing app input
            $identity = $this->input->post('identity', true);
            $password = $this->input->post('password', true);
            var_dump($identity);
            exit;

still no output.

#4
[eluser]InsiteFX[/eluser]
How do you expect to get input from your label names?

identity and password should be assigned to your input name= fields!

Code:
&lt;form action="http://localhost/ionauth1/index.php/auth/login" method="post" accept-charset="utf-8"&gt;    
      <p>
       <label for="identity">Email/Username:</label>

       &lt;input type="text" name="identity" value=""  /&gt;      </p>
      
      <p>
       <label for="password">Password:</label>
       &lt;input type="text" name="password" value=""  /&gt;      </p>
      
    
      <p>&lt;input type="submit" name="submit" value="Login"  /&gt;&lt;/p>

      
    &lt;/form&gt;

#5
[eluser]CroNiX[/eluser]
Ha, good catch

#6
[eluser]bill19[/eluser]
Thanks for taking a look at this.

I've changed the controller like so:

Code:
else{
        
            $data=array();
            $data['identity']='identity';
            $data['password']='password';
            $data['message']='';

            $this->load->view('auth/login',$data);

This results in the form looking like:

Code:
&lt;form action="http://localhost/ionauth1/index.php/auth/login" method="post" accept-charset="utf-8"&gt;    
      <p>
       <label for="identity">Email/Username:</label>

       &lt;input type="text" name="identity" value=""  /&gt;      </p>
      
      <p>
       <label for="password">Password:</label>
       &lt;input type="text" name="password" value=""  /&gt;      </p>
      
      
      <p>&lt;input type="submit" name="submit" value="Login"  /&gt;&lt;/p>

Once again, no output is generated.

Its got to be something to do with the controller routing:

I notice the first time through in my test environment it says http://localhost/ionauth1/
the full path for this is http://localhost/ionauth1/index.php/auth2/login which I have set in the /config/routes folder ( I have confirmed this ).

After submitting though it goes to http://localhost/ionauth1/index.php/auth/login, which is a different controller..

#7
[eluser]bill19[/eluser]
Hi again guys,

I think I figured it out.

In my controller folder I had a controller called 'auth', and a second controller called 'auth2' ( I was writing my code in 'auth2' ). I am not sure why, but after submitting the form control went directly to 'auth' (alphabetically before auth2 in controller folder?), not auth2 as I expected. I got rid of the original auth and renamed 'auth2' to 'auth' and now it works.

Does this make any sense?

Bill


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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