php表单$ _POST不包含提交属性名称和值对

时间:2014-05-25 07:32:20

标签: php html forms

<div class="panel panel-default" style="border-top-color: white">  
<div class="panel-body">  
   <div class="panel panel-default">  
    <div class="panel-heading">
      <div class="row">
        <div class="col-md-2">
        <h4 class="panel_title"><?=__("Edit Agent")?></h4>
        </div>
      <div class="col-md-4">
        <input type="text" class="form-control" id="agent_search_input"
                            name="agent_search_input"
                            placeholder="Enter Code,Email or Phone Number">
     </div>
    <div class="col-md-2">
    <button class="btn btn-default" name="search_agent_btn" id="search_agent_btn">  Search Agent</button>
    </div>
     </div>
  </div>
<div class="panel-body">
    <?php  echo"<h4>".__( "Details:" )."</h4>"; ?>
    <form id="agent_form_edit" name="agent_form_edit" method="post"
        action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>">
    <?php wp_nonce_field('test');?>
<input id="agent_id_handle" name="agent_id_handle" type="hidden" value="">
<input id="agent_address_id_handle" name="agent_address_id_handle" type="hidden" value="">
  <div class="row">
    <div class="col-md-2">
     <div class="form-group">
<input class="form-control" type="text" placeholder="<?php _e("Agent Unique Code " ); ?>" name="agent_code_edit" id="agent_code_edit">
    </div>
       </div>
    <div class="col-md-4">
     <div class="form-group">
<input type="text" class="form-control" placeholder="<?php _e("Enter distributer number" ); ?>" name="distributer_phone_number_edit"                            id="distributer_phone_number_edit">
         </div>
        </div>
  </div>
<!-- end of row -->
 <div class="row">
   <div class="col-md-2">
     <div class="form-grop">
    <input type="text" class="form-control"
        placeholder="<?php _e("First Name " ); ?>"
        name="agent_first_name_edit" id="agent_first_name_edit">
    </div>
  </div>
      <div class="col-md-2">
      <div class="form-group">
    <input class="form-control" type="text"                     name="agent_last_name_edit" placeholder="<?php _e("Last Name " ); ?>"
id="agent_last_name_edit">
   </div>
 </div>
 <div class="col-md-2">
  <div class="form-group">
   <input class="form-control" type="text"
    placeholder="<?php _e("Father Name " ); ?>"
            name="agent_father_name_edit" id="agent_father_name_edit">
  </div>
                        </div>
                    </div>
                    <!-- end of row -->

                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" placeholder="<?php _e("Phone #1" ); ?>"
                                    class="form-control" name="agent_phone_number1_edit"
                                    id="agent_phone_number1_edit">
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" placeholder="<?php _e("Phone #2" ); ?>"
                                    class="form-control" name="agent_phone_number2_edit"
                                    id="agent_phone_number2_edit">
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" placeholder="<?php _e("Email" ); ?>"
                                    class="form-control" name="agent_email_edit"
                                    id="agent_email_edit">
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <hr>
        <?php  echo"<h4>".__( "Address:" )."</h4>"; ?>
        <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <label for="agent_province"><?php _e("Provinces" ); ?></label> <select
                                    name="agent_province_edit" id="agent_province_edit"
                                    class="province form-control">
                                    <option value="" selected="selected" disabled="disabled">Select
                                        a province</option>
                        <?php foreach (provinces() as $p):?>
                            <option value="<?=$p->id?>"><?=$p->name?></option>
                        <?php endforeach;?>
                    </select>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <label for="agent_district"><?php _e("Districts" ); ?></label> <select
                                    name="agent_district_edit" id="agent_district_edit"
                                    class="district form-control">
                                    <option disabled="disabled">Select a province First</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" name="agent_city_edit" class="form-control"
                                    placeholder="<?php _e("City" ); ?>" value="<?php echo $city;?>"
                                    id="agent_city_edit">
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" name="agent_street_edit" class="form-control"
                                    placeholder="<?php _e("Street" ); ?>"
                                    value="<?php echo $street;?>" id="agent_street_edit">
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" placeholder="<?php _e("Latitude " ); ?>"
                                    class="form-control" value="<?php echo $latitude;?>"
                                    name="agent_latitude_edit" id="agent_latitude_edit">
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="text" class="form-control"
                                    placeholder="<?php _e("Longtitude" ); ?>"
                                    value="<?php echo $longtitude;?>" name="agent_longtitude_edit"
                                    id="agent_longtitude_edit">
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <hr>
        <?php  echo"<h4>".__( "Active Products and Sales Method:" )."</h4>"; ?>
        <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <select name="agent_sales_method_edit"
                                    id="agent_sales_method_edit" class="form-control">
                                    <option disabled="disabled" selected="selected">Select Sales
                                        Method</option>
                        <?php foreach (sales_methods() as $sm):?>
                            <option value="<?=$sm->id?>"><?=$sm->method?></option>
                        <?php endforeach;?>
                    </select>
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <select name="agent_active_products_edit[]"
                                    id="agent_active_products_edit" class="form-control"
                                    multiple="multiple">
                                    <option value="" selected="selected" disabled="disabled">Select
                                        Active Products</option>
                            <?php foreach (active_products() as $ap):?>
                                <option value="<?=$ap->id?>"><?=$ap->name?></option>
                            <?php endforeach;?>
                    </select>
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
            <?php  echo"<h4>".__( "Agent Type:" )."</h4>"; ?>
            <div class="row">
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="radio" name="agent_type_edit"
                                    id="agent_type_independent" class="form-control"
                                    value="independent">Independent
                            </div>
                        </div>
                        <div class="col-md-2">
                            <div class="form-group">
                                <input type="radio" class="form-control" name="agent_type_edit"
                                    id="agent_type_sub" value="sub_agent">Sub Agent
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <input type="hidden" name="agent_phone_number_edit"
                                    class="form-control" id="agent_phone_number_edit"
                                    placeholder="enter parent agent's phone number">
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <div class="row">
                        <div class="col-md-4">
                            <div class="form-group">
                                <select name="agent_status_edit" id="agent_status_edit"
                                    class="form-control">
                                    <option value="" selected="selected" disabled="disabled">Activate/Deactivate
                                        Agent</option>
                                    <option value="active">Active</option>
                                    <option value="inactive">Inactive</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!-- end of row -->
                    <hr>
                    <div class="row">
                        <div class="col-md-1">
                            <div class="form-group">
                                <input type="submit" name="submit"
                                    value="Update Agent" class="btn btn-default" />
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

每当我调试$ _POST时,它都包含除输入字段以外的所有表单属性,其类型为&#39; submit&#39;并命名&#39; submitForm&#39;。

如果我将输入字段的名称更改为&#39;提交&#39;然后$ _POST也显示提交输入的键值对。

我无法弄清楚它是否像洙一样。

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

我测试了你的HTML代码

Array
(
    [agent_id_handle] => 
    [agent_address_id_handle] => 
    [agent_phone_number_edit] => 
    [submit] => Update Agent
)

一切正常

你应该print_r($_POST)在你的代码开始时发现它是否存在

可能是某个unset()