views:

41

answers:

2

Hi I've just started couple of days ago with codeigniter, I have a following problem. When I set value of login button to "" (no value) in order to style it with css properly the login form won't work, the value needs to be login, is there a way arround it I'm sure there is got to be the way.. Here is some code ..

Controller :

<?php

class Login extends Controller {
//  var $success = '';


    function Login()
    {
     parent::Controller();
    }

    function index()
    {
     $success_tmp   = '0';
     $this->load->model('Member');

     $this->load->helper(array('form', 'url'));
     $this->load->library(array('encrypt', 'form_validation', 'session'));



     $this->form_validation->set_rules('member_username', 'User', 'required');
     $this->form_validation->set_rules('member_pass', 'Password', 'required');

     $this->form_validation->set_error_delimiters('<em>','</em>');



     if($this->input->post('login'))
     {
      if($this->form_validation->run())
      {
       if ($this->Member->check_login() == 1 ) 
       {
      // $this->session->set_userdata('');
       redirect('index_main');

       $success_tmp = 1;
       }
      }
     } 
     if ($success_tmp != 1) 
     {
      $this->load->view('header');
      $this->load->view('login_form');
      $this->load->view('footer');
     }
    }

    function logout()
    {
     $this->load->library('session');
     $this->load->helper(array('url'));
     $this->session->sess_destroy();
     redirect('login/index/');
    }





}


Here is my view file :

<div id="page-top"><h1>Existing users</h1></div>

<div class="login_center">
<div class="login_logo"></div>

<?$attributes = array('class' => 'login_form', 'id' => 'login_form');?>
<?$login_dugme = array('class' => 'login_button', 'name' => 'login', 'value' => 'login');?>
<?=form_open('login/index/', $attributes);?>





     <ul class="login_form">
                 <li>
      <?=form_label('Username', 'member_username')?>
      <?=form_input('member_username', set_value('member_username'))?>
            <?=form_error('member_username')?>
     </li>

     <li>
      <?=form_label('Password', 'member_pass')?>
      <?=form_password('member_pass')?>
            <?=form_error('member_pass')?>
     </li>
               </ul>









</div>
<div class="login_bottom"><?=form_submit($login_button);?></div>
<?=form_close();?>
A: 
if(isset($this->input->post('login')))

should solve your problem.

Joscha
I get error when I use that Fatal error: Can't use method return value in write context in
Gandalf StormCrow
Where did you put it? You should replace if($this->input->post('login')) by if(isset($this->input->post('login'))) that it also works if the post value of the login button is transmitted, but empty.
Joscha
A: 

Maybe use a space instead of "" for the button... It may work.

alexy13