Php 代码点火器表单未发送Post数据

Php 代码点火器表单未发送Post数据,php,codeigniter,Php,Codeigniter,我的CI2.0.2应用程序有一个小问题 据我所知,它没有从表单中获取任何post数据,因此无法运行更新功能,尽管大多数页面工作正常 表格如下: <?php echo form_open('job/update/', array('id' => 'update', 'name' => 'update')); ?> <div class="images"> <?php echo img('application/images/updateJob.

我的CI2.0.2应用程序有一个小问题

据我所知,它没有从表单中获取任何post数据,因此无法运行更新功能,尽管大多数页面工作正常

表格如下:

<?php echo form_open('job/update/', array('id' => 'update', 'name' => 'update')); ?>

<div class="images">

    <?php echo img('application/images/updateJob.png');?>

</div>

<h1>Update Job</h1>
<br><br><br><br>


<div class="fieldset">

    <?php
        if (isset($error))
        {
            echo '<div id ="error">';
            echo '<h2>Error:</h2>';
            echo '<p>'.$error.'</p>';
            echo '</div>';
        }
    ?>

    <input type="hidden" name="c" id='c' value="<?php if(!empty($view[0])) { echo $view[0]; } else { echo "0"; }    ?>">
    <div class="left">
        <h4>Job Details:</h4>
        <div>
            <label for="job_number">Job No:</label>
            <input type="text" name="job_number" id="job_number" value="<?php echo $job['jobno']; ?>" disabled="disabled">
        </div>

        <div>
            <label for="date">Date:</label>
            <input type="text" name="date" id="date" value="<?php echo $job['datetime']->format('d-M-Y'); ?>">
        </div>

        <div>
            <label for="council">Council:</label>
            <input type="text" name="council" id="council" value="<?php echo htmlspecialchars($job['council']); ?>"> *
        </div>

        <div>
            <label for="dano">DA No:</label>
            <input type="text" name="dano" id="dano" value="<?php echo htmlspecialchars($job['dano']); ?>">
        </div>

        <div>
            <label for="client">Client:</label>
            <input type="text" name="client" id="client" value="<?php echo $job['clientid']; ?>" disabled="disabled">           
        </div>

    </div>


    <div class="right" style="margin-left: 390px;">
        <h4>Location:</h4>
        <label for="street_no">Street No:</label>
        <input type="text" name="street_no" id="street_no" value="<?php echo $address['streetno']; ?>"> *
        <br>

        <label for="street_name">Street Name:</label>
        <input type="text" name="street_name" id="street_name" value="<?php echo $address['streetname']; ?>"> *
        <br>

        <label for="street_type">Street Type:</label>
        <select name="street_type" id="street_type">
        <?php
            foreach ($street_types as $type)
            {
                echo '<option';
                if ($type == $address['streettype']) echo ' selected="selected"';
                echo '>'.$type.'</option>';
            }
        ?>
        </select> *
        <br>

        <label for="suburb">Suburb:</label>
        <input type="text" name="suburb" id="suburb" value="<?php echo $address['suburb']; ?>"> *
        <br>

        <label for="postcode">Postcode:</label>
        <input type="text" name="postcode" id="postcode" value="<?php echo $address['postcode']; ?>"> *
        <br>

        <label for="state">State:</label>
        <input type="text" name="state" id="state" value="<?php echo $address['state']; ?>"> *
        <br>

        <label for="country">Country:</label>
        <input type="text" name="country" id="country" value="<?php echo $address['country']; ?>">
        <br>

        <label for="dp">DP:</label>
        <input type="text" name="dp" id="dp" value="<?php echo $address['dp']; ?>">
        <br>

        <label for="lot_no">Lot No:</label>
        <input type="text" name="lot_no" id="lot_no" value="<?php echo $address['lotno']; ?>">
        <br>

        <label for="po_box">PO Box:</label>
        <input type="text" name="po_box" id="po_box" value="<?php echo $address['pobox']; ?>">

    </div>


    <div>
        <input type="submit" id="submit" name="submit" value="Submit" class="button">
        <p>* = Required fields</p>
    </div>

</div>

<?php echo form_close();?>
/**
 * Update an existing job.
 * @param   int $job_number     The number of the job to update.
 */
public function update($job_number=0)
{
    $this->load->model('Job_model');
    $job     = array();
    $address = array();

    // Get post data.
    $job['joblocation'] = '';
    $job['jobno']       = $this->input->post('job_number');
    $job['datetime']    = new DateTime($this->input->post('date'));
    $job['dano']        = $this->input->post('dano');
    $job['council']     = $this->input->post('council');
    echo $job['jobno'];
    echo $job['dano'];
    echo $job['council'];
    $address['streetno']    = $this->input->post('street_no');
    $address['streetname']  = $this->input->post('street_name');
    $address['suburb']      = $this->input->post('suburb');
    $address['country']     = $this->input->post('country');
    $address['postcode']    = $this->input->post('postcode');
    $address['state']       = $this->input->post('state');
    $address['dp']          = $this->input->post('dp');
    $address['lotno']       = $this->input->post('lot_no');
    $address['pobox']       = $this->input->post('po_box');
    $address['streettype']  = $this->input->post('street_type');
    echo "here2";
    if (isset($_POST['submit']))
    {
        $this->Job_model->update($job);
        echo "here";
        redirect('job/');
    }

    // Otherwise, get the data from the database.       
    else
    {
        $job = $this->Job_model->search($job_number);
        $job = $job[0];
        $job['datetime'] = new DateTime($job['datetime']);
        $address = $this->Job_model->get_address($job['joblocation']);
        $address = $address[0];
    }


    // Get the street types.
    $street_types = array();
    $this->load->model('staff_model');
    $streets = $this->staff_model->get_street_types();

    foreach ($streets as $street) 
    {
        $street_types[$street['streettype']] = $street['streettype'];
    }


    // Load the client list.
    $clients = array();
    $this->load->model('client_model');
    $people = $this->client_model->get_client_person_list();
    $companies = $this->client_model->get_client_company_list();


    // Allocate view data.
    $viewdata = array();
    $viewdata['job'] = $job;
    $viewdata['street_types'] = $street_types;
    $viewdata['address'] = $address;
    $viewdata['people'] = $people;
    $viewdata['companies'] = $companies;

    $this->layout->view('job/update', $viewdata);
}
你知道为什么会这样吗

提前感谢,


James

尝试更改您在此行中使用的引号:

<input type="hidden" name="c" id='c' value="<?php if(!empty($view[0])) { echo $view[0]; } else { echo '0'; }    ?>" />

使用0前后的双引号时,您正在破坏该php,因为第一个引号将关闭起始值引号。

尝试将isset$\u POST['submit']更改为var_dump$\u POST,看看有什么结果。是否加载了表单helper$this->load->helper'form';?我应该提到的是,我是从以前的工作中扩展这个应用程序的,那不是我的。我还应该提到,使用form_open和form_close的其他页面也可以工作,因此我假设它会自动加载form helper。我不确定我在使用var_dump时得到了array0{}你知道发生了什么吗?我现在有一个类似的问题。不幸的是,这没有改变任何事情,但我看到了你的观点,并修复了它。谢谢你指出这一点。