在数据库codeigniter中插入值时,提交按钮不起作用

时间:2017-02-25 09:30:11

标签: forms codeigniter

我在codeigniter中创建了一个表单。我不知道发生了什么。当我点击提交时,我的提交按钮不起作用..

这是我的观看代码:

<form method="post" action="<?php echo base_url().'Candidate/candidate_process' ?>">

    <b>Date </b>:<input type="text" name="date" id="date"><br><br>

    <div class="form-group">

        <label>Choose  Candidate</label>
        <select class="form-control" name="candidate_id">
            <option value="" disabled selected>Select Candidate</option>

            <?php foreach($candidate as $rows) { ?>
            <option value="<?php echo $rows->candidate_id?>"><?php echo ucfirst($rows->first_name)?></option>
            <?php } ?>

        </select>
    </div><br></br>



    <div class="form-group">

        <label>Choose  Vendor</label>
        <select class="form-control" name="user_id">
            <option value="" disabled selected>Select Vendor</option>

            <?php foreach($usertype as $rows) { ?>
            <option value="<?php echo $rows->user_id?>"><?php echo ucfirst($rows->first_name)?></option>
            <?php } ?>

        </select>
    </div><br></br>


    <div class="form-group">
        <label><b>Select Status:</b></label>
        <select class="form-control" name="status_type_id">
            <option value="" disabled selected>Status Type</option>

            <?php foreach($statustype as $rows) { ?>
            <option value="<?php echo $rows->status_type_id?>"><?php echo ucfirst($rows->status)?></option>
            <?php } ?>

        </select>
    </div><br>

    <div class="form-group">
        <label><b>Select Interview Type:</b></label>
        <select class="form-control" name="selection_id">
            <option value="" disabled selected>Interview Type</option>

            <?php foreach($interviewtype as $rows) { ?>
            <option value="<?php echo $rows->interview_type_id?>"><?php echo ucfirst($rows->interview_type_name)?></option>
            <?php } ?>

        </select>
    </div><br>

    <div class="form-group">
        <label><b>Selection Process:</b></label>
        <select class="form-control" name="selection_process_id">
            <option value="" disabled selected>Selection Process Type</option>

            <?php foreach($selectionprocess as $rows) { ?>
            <option value="<?php echo $rows->selection_process_id?>"><?php echo ucfirst($rows->selection_process)?></option>
            <?php } ?>

        </select>
    </div><br>

    <button type="button" name="submit" value="submit" class="btn btn-primary">Submit</button>

</form>

控制器代码:

function candidate_process($candidateid){  

    $data["msg"]="";
    $this->load->model('CandidateModel');
    $data['statustype']=$this->CandidateModel->getstatustypes();
    $data['interviewtype']=$this->CandidateModel->getinterviewtypes();
    $data['selectionprocess']=$this->CandidateModel->getselectionprocess();
    $data['candidate']=$this->CandidateModel->getcandidates();
    $data['usertype']=$this->CandidateModel->getvendors();
    $data['getCandidate'] = $this->CandidateModel->get_candidate_detail($candidateid);

    if($this->input->post()) { 
        $this->CandidateModel->add_candidate_selection($this->input->post());
    }

    $this->load->view('Candidates/candidate_process',$data);
}

型号:

public function add_candidate_selection($data){ 
    $data=array(
        'candidate_id'=>$this->input->post('candidate_id'),
        'user_id'=>$this->input->post('user_id'),
        'status_type_id'=>$this->input->post('status_type_id'),
        'interview_type_id'=>$this->input->post('interview_type_id'),
        'selection_process_id'=>$this->input->post('selection_process_id'),
        'date'=>$this->input->post('date')

        );
    $this->db->insert('candidate_selection', $data);
}

任何人都可以帮助我吗?我没有弄到错误的地方。

1 个答案:

答案 0 :(得分:1)

按钮类型必须为submit

<button type="submit" name="submit" value="submit" class="btn btn-primary">Submit</button>