代码点火器上的引导程序错误


Bootstrap bugs on codeigniter?

也许视频可以很容易地解释这个问题。这是我视频的链接。

这是view代码

<div class="col-sm-4">

<?php echo form_open('user/updateuser');
  ?>

<legend>Update User</legend> 

<div class="form-group">
    <label for="id">ID</label>
    <input name="id" type="text" class="form-control" id="id" placeholder="Input id" value="<?php echo $id; ?>" disabled>
     <?php echo form_error('id'); ?>     
  </div>
<div class="form-group">
    <label for="username">Username</label>
    <input name="username" type="input" class="form-control" id="username" placeholder="Input Username" value="<?php echo $username;?>">
     <?php echo form_error('username'); ?>   
  </div>
  <div class="form-group">
    <label for="password">Old Password:</label>
    <input name="old_password" type="password" class="form-control" id="password" placeholder="Input Old Password"" value ="<?php set_value('old_password');?>">
    <?php echo form_error('old_password')?>
  </div>
  <div class="form-group">
    <label for="password">New Password:</label>
    <input name="password" type="password" class="form-control" id="password" placeholder="Input Password" ">
    <?php echo form_error('password')?>
  </div>

  <div class="form-group">
    <label for="password">New Password Confirmation:</label>
    <input name="password_conf" type="password" class="form-control" id="password" placeholder="Input Password Confirmation">
    <?php echo form_error('password_conf')?>
  </div>
  <div class="form-group">
        <label for="email">Email address</label>
        <input name="email" type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email" value="<?php echo $email; ?>">
        <?php echo form_error('email')?>
  </div>      
  <div class="form-group" align="center">
    <button type="submit" class="btn btn-success">Submit</button> 
<button type="reset" class="btn btn-danger">Clear</button>
      </div>
 </div>  
  <?php 
    echo form_close(); 
  ?>

这是控制器user/updateuser

function index()
{
    //This method will have the credentials validation    
    $this->form_validation->set_error_delimiters('<div class="alert alert-danger" role="alert">', '</div>');
    $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean');
    $this->form_validation->set_rules('old_password', 'Old Password', 'trim|required|xss_clean|callback_check_password');
    $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean|matches[password_conf]');
    $this->form_validation->set_rules('password_conf', 'Password Confirmation', 'trim|required|xss_clean');
    $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean');
    if($this->isloggedin('logged_in'))
    {                           
        if($this->form_validation->run() == FALSE)
        {                       
            $data = array(
                'sess_username' =>  $this->isloggedin('logged_in'),
                'id'            =>  $this->input->post('id'),
                'username'      =>  $this->input->post('username'),
                'email'         =>  $this->input->post('email')
            );                                  
            $this->load->view('header');
            $this->load->view('main/menu_super_admin',$data);
            $this->load->view('user/modifuser');                
            $this->load->view('footer');
        }
        else
        {           
            $query = $this->m_user->updateuser($this->input->post('id'),$this->input->post('username'),md5($this->input->post('password')),$this->input->post('email'));
            if($query)
            {
                echo "<script>window.onload = function() { return alert('" Update User Success ! '"); }</script>";
            }
            else 
            {
                return false;
            }
        redirect('user/user', 'refresh');
          }
    }
    else
    {
        redirect('login', 'refresh');
    }
}

问题是,我想让禁用的输入保持禁用状态,并且值保持不变,

我的代码有错误吗?

禁用的输入不会发布到服务器:http://www.w3.org/TR/html401/interact/forms.html#disabled

[禁用的输入]无法接收用户输入,其值也不会与表单一起提交。

我建议从会话中获取ID,不要以任何方式依赖发布的信息(这是一个安全问题,因为发布的信息可能会被最终用户操纵)。您已经检查了用户是否已登录。只需在会话中获取ID即可。

会话ID可以这样检索:

$data = array(
    'sess_username' =>  $this->isloggedin('logged_in'),
    'id'            =>  $this->session->userdata('session_id'),
    'username'      =>  $this->input->post('username'),
    'email'         =>  $this->input->post('email')
); 

您可能还需要首先加载库

$this->load->library('session');

我还建议使用文档中提到的sess_use_database来增加会话安全性。