[PHP] Code Igniter Developers

[PHP] Code Igniter Developers

968 members
  • Join

    When you join a group, other members will be able to see your profile and message you. The group logo will be visible on your profile unless you change that setting.

  • Information and settings

Have something to say? Join LinkedIn for free to participate in the conversation. When you join, you can comment and post your own discussions.

Tunde

My submit button is not submitting using code igniter. I have this in my view file <?php echo form_open("user/index"); .............. echo form_submit('submit', 'login');

Software Engineer at Federal University of Technology Akure

echo form_close();
?>

I have this in my User/Index

if ($this->input->post('username') AND $this->input->post('password'))
{
echo username;
echo password;
}
else
{
echo 'invalid username or password';
}

  • Comment (7)
  • December 2, 2011
  • Close viewer

Comments

  • Zathrus W.

    Zathrus

    Zathrus W.

    Web Developer at Wide Media Group s.r.o.

    it might be because your echo statements don't use variables but constants... should probably be more like:

    if ($this->input->post('username') AND $this->input->post('password'))
    {
    echo $this->input->post('username');
    echo $this->input->post('password');
    }

  • Tunde O.

    Tunde

    Tunde O.

    Software Engineer at Federal University of Technology Akure

    @Zathrus, Even in Code Igniter?

  • Gabriel Federico R.

    Gabriel Federico

    Gabriel Federico R.

    Software Developer - Harriague + Asociados

    Hi Tunde, your problem is in the controller for me, you can see if the varibles are sent by the form, doing a print_r($_POST); before if to see if they are in the controller, it will give you an idea if you send or no. If you submit the data then the problem is in the programming. I recommend using if (isset($this->input->post ('username')) && isset($this->input->post ('password'))) and the echo do echo $this->input->post ('username'); echo $this->input->post ('password'); I hope you help

  • Harry osmar S.

    Harry osmar

    Harry osmar S.

    programmer at PT. CTE

    Code igniter has maked handling request(POST) become simple, just check this code, i get it from code-igniter user_guide

    before

    if ( ! isset($_POST['something']))
    {
    $something = FALSE;
    }
    else
    {
    $something = $_POST['something'];
    }

    becoming

    $something = $this->input->post('something');

  • Tri N.

    Tri

    Tri N.

    Server Engineer at Midverse Studios

    actually you can get $_POST request by using

    // return true if it's POST request
    if ($this->input->post()) {
    // you can assign POST request with variable, if TRUE is set, it'll prevent xss attack, or you can set in config to prevent every POST/GET request throughout the site
    $post = $this->input->post(TRUE);
    //now you can do whatever with $post variable
    echo $post['username'];
    echo $post['password'];

    }

  • Hasitha P.

    Hasitha

    Hasitha P.

    Computer Software Professional

    I think the best way to check whether the form was submitted is to use this

    if($this->input->server('REQUEST_METHOD') == 'POST')
    {
    // Handle form values
    }

  • Robert R.

    Robert

    Robert R.

    Principal Software Engineer

    1. In form_open("user/index") define what type of method you are using POST/GET
    2. remember upper and lower case names matters (make sure you are pointing to the right controller/method)
    3. you can always debug it by print_r($this->input); above your if statement to display what you have submitted
    4. you do not need point to index method as CI already does it automatically
    5. your index method in user controller must be a public method
    6. if everything above fails then check your routing configuration

Have something to say? Join LinkedIn for free to participate in the conversation. When you join, you can comment and post your own discussions.

Feedback