2017-06-02 62 views
0

我正在尝试从HTML,PHP进行故障排除。前台模板很聪明。

当我做了一些var_dump($_POST)像复选框形式值,显示null value`

,但是当我使用var_dump($_REQUEST)它正确地出现。

表单设置为method=post

此外如果我从浏览器复制整个html并在本地主机上检查它,var_dump($_POST)正确显示值。

那么使用$_POST时可能缺少数值的原因是什么,无法完成?

文件update_profile.tpl的内容是这样的:

附代码剥离版本,空间的限制;

所有的
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> 
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> 
<div class="big-left"> 
    <div class="btop-data-left"> 
     <h2>Update Profile</h2> 
    </div> 
    <div class="clear"></div> 
    <div class="clear"></div> 
    {if $successMsg != ''} 
     <div class="success">{$successMsg}</div> 
    {/if} 
    <br/> 
</div> 
{if $flagUpdate} 
    <div style="float:right;"> 
    <!--<a href="{$Site_Root}tutor_profile_admin.php?tutor_id={$tutorData->tutor_id}">View Profile</a>--> 
    {if $backPage=='tutProf'} 
     <a href="{$Site_Root}tutor_profile_admin.php?tutor_id={$tutorData->tutor_id}">&laquo; Back</a> 
    {/if} 
    {if $backPage=='tutSear'} 
     <a href="{$Site_Root}admin_advance_search.php">&laquo; Back</a> 
    {/if} 
    </div> 
    {/if} 
<form action="" method="post" class="frmRegister" name="frmRegister" id="frmRegister" enctype="multipart/form-data" > 
    <div class="tutor-registration"> 
     <div class="ttr-rg-title"> Personal Particulars & Contacts Details <span>(this field is compulsory)</span> </div> 
     <br> 
     <br> 
     <div class="tutor-registration-form"> 


      <div class="tab-content" id="level"> 
       <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
        <tbody> 
        {section name=rec loop=$levelCount} 
         <tr> 
          <td valign="top" style="padding-bottom: 15px;"><input type="checkbox" name="ls[]" id="selectAll{$smarty.section.rec.iteration}"><b>{$level_name[rec]}</b> 
          <br /> 
           {section name=rec1 loop=$subCount[rec]} 
           {assign var="k" value="$level_id[rec]"} 

           <input type="checkbox" value="{$subject_id[rec][rec1]}" name="level_subject[{$level_id[rec]}][]" {if $subject_id[rec][rec1]|in_array:$level_subject.$k}checked{/if} class="{$level_id[rec]}{$smarty.section.rec.iteration}"/> 
           <font class="bodytext">{$subject_name[rec][rec1]}</font> 
           {/section} 
          </td> 
         </tr> 
         {literal} 
         <script> 
          $(document).ready(function() { 
           $('#selectAll{/literal}{$smarty.section.rec.iteration}{literal}').click(function(event) { //on click 
            if(this.checked) { // check select status 
             $('.{/literal}{$level_id[rec]}{$smarty.section.rec.iteration}{literal}').each(function() { //loop through each checkbox 
              this.checked = true; //select all checkboxes with class "checkbox1" 
             }); 
            }else{ 
             $('.{/literal}{$level_id[rec]}{$smarty.section.rec.iteration}{literal}').each(function() { //loop through each checkbox 
              this.checked = false; //deselect all checkboxes with class "checkbox1" 
             }); 
            } 
           }); 

          }); 
         </script> 
         {/literal} 
        {/section} 
        </tbody> 
       </table> 
      </div> 
      <div class="tab-content" id="experience"> 
       <table width="100%" cellspacing="0" cellpadding="0" border="0"> 
        <tbody> 
         <tr> 
          <td width="60%" valign="top"><font class="bodytext"> 
          You are encouraged to write a short description of yourself, teaching experience and teaching method. If you are teaching or have taught in any school/institution, you are advise to include the same name of the school/institution you teaching/taught in, and the level/s and subject/s you teaching there. You can always log in to edit this later.<br> 
           <br><b>Example:</b> <i>I have one year experience teaching a primary 5 and secondary 2.</i> or <i>After giving tuition to a sec 3 girl, her grades have improved from B3 to A1.</i></font><br> 
           <br> 
           <textarea rows="10" cols="100" name="experience">{$tutorData->experience}</textarea> 
          </td> 
          <td width="5%">&nbsp;</td> 
          <td valign="top"> Years of Experience<br> 
           <select name="year_experience"> 
                 <option {if $tutorData->year_experience == '0'} selected="true" {/if} value="0">0</option> 
            <option {if $tutorData->year_experience == '1'} selected="true" {/if} value="1">1</option> 
            <option {if $tutorData->year_experience == '2'} selected="true" {/if} value="2">2</option> 
            <option {if $tutorData->year_experience == '3'} selected="true" {/if} value="3">3</option> 
            <option {if $tutorData->year_experience == '4'} selected="true" {/if} value="4">4</option> 
            <option {if $tutorData->year_experience == '5'} selected="true" {/if} value="5">5</option> 
            <option {if $tutorData->year_experience == '6'} selected="true" {/if} value="6">6</option> 
            <option {if $tutorData->year_experience == '7'} selected="true" {/if} value="7">7</option> 
            <option {if $tutorData->year_experience == '8'} selected="true" {/if} value="8">8</option> 
            <option {if $tutorData->year_experience == '9'} selected="true" {/if} value="9">9</option> 
                <option {if $tutorData->year_experience == '10'} selected="true" {/if} value="10">10</option> 
                <option {if $tutorData->year_experience == '11'} selected="true" {/if} value="11">11</option> 
                <option {if $tutorData->year_experience == '12'} selected="true" {/if} value="12">12</option> 
                <option {if $tutorData->year_experience == '13'} selected="true" {/if} value="13">13</option> 
                <option {if $tutorData->year_experience == '14'} selected="true" {/if} value="14">14</option> 
                <option {if $tutorData->year_experience == '15'} selected="true" {/if} value="15">15</option> 
                <option {if $tutorData->year_experience == '16'} selected="true" {/if} value="16">16</option> 
                <option {if $tutorData->year_experience == '17'} selected="true" {/if} value="17">17</option> 
                <option {if $tutorData->year_experience == '18'} selected="true" {/if} value="18">18</option> 
                <option {if $tutorData->year_experience == '19'} selected="true" {/if} value="19">19</option> 
                <option {if $tutorData->year_experience == '20'} selected="true" {/if} value="20">20</option> 
            <option {if $tutorData->year_experience == '20+'} selected="true" {/if} value="20+">More than 20</option> 
           </select> 
          </td> 
         </tr> 
        </tbody> 
       </table> 
      </div> 

          <td> 
           <input type="text" name="result[]" maxlength="50" value="{$result[langdet]}" /> 
          </td> 
          <td><a href="javascript:void(0)" id="tr_{$lgid[langdet]}" onclick='javascript: $(this).parent().parent().remove();'><img src="{$Templates_Image}remove.png" alt="" /></a> </td> 
         </tr> 
         {/section} 
        </tbody> 
       </table> 
       <input type="hidden" name="lgcnt" value="{$langCount}"> 
       <table width="100%" cellspacing="0" cellpadding="3" border="0" class="languages" style="display:none;"> 
        <tbody> 
         <tr> 
          <td width="17%"> 
           <select id="language_code" name="language_code[]"> 
              <option value=""></option> 
              {$languageList} 
             </select> 
          </td> 
          <td width="10%"> 
           <input type="checkbox" value="1" name="primary_flag[]" onchange="javascript: checkUncheckLang(this);"> 
           <input type="hidden" name="primary_flag_hidden[]" value="0"> 
          </td> 
          <td width="10%"> 
           <select id="spoken_level" name="spoken_level[]"> 
             <option value=""></option> 
             <option value="10">10</option> 
             <option value="9">9</option> 
             <option value="8">8</option> 
             <option value="7">7</option> 
             <option value="6">6</option> 
             <option value="5">5</option> 
             <option value="4">4</option> 
             <option value="3">3</option> 
             <option value="2">2</option> 
             <option value="1">1</option> 
             <option value="0">0</option> 
           </select> 
          </td> 
          <td width="10%"> 
           <select id="written_level" name="written_level[]"> 
             <option value=""></option> 
             <option value="10">10</option> 
             <option value="9">9</option> 
             <option value="8">8</option> 
             <option value="7">7</option> 
             <option value="6">6</option> 
             <option value="5">5</option> 
             <option value="4">4</option> 
             <option value="3">3</option> 
             <option value="2">2</option> 
             <option value="1">1</option> 
             <option value="0">0</option> 
           </select> 
          </td> 
          <td width="25%"> 
           <select id="certificate_code" name="certificate_code[]"> 
            <option value="">- Select Certificate -</option> 
            {$certiList} 
           </select> 
          </td> 
          <td width="15%"> 
           <input type="text" name="result[]" maxlength="50" /> 
          </td> 
          <td width="13%"><a href="javascript:void(0)" onclick='javascript: $(this).parent().parent().parent().parent().remove();'><img src="{$Templates_Image}remove.png" alt="" /></a> </td> 
         </tr> 
        </tbody> 
       </table> 

       </div> 
       <a href="javascript:void(0)" class="add-lang" onclick='javascript: $(".languages").clone().appendTo(".languageList").show().removeClass("languages");'><img src="{$Templates_Image}pls.png">Add Language</a> 
       <!--<br /><br /><strong>Tuition Jobs Portal English Language Assessment - <a href="#">Help</a> </strong>--> 
      </div> 
      <div class="tab-content tabresults" id="skillsmusic"> 
       <div class="skillList"> 
       <table width="100%" cellspacing="0" cellpadding="3" border="0"> 
        <tbody> 
         <tr> 
          <td width="18%"><u>Skills/Music</u></td> 
          <td width="13%"><u>Proficiency</u></td> 
          <td width="22%"><u>Relevant Certificates (Optional)</u></td> 
          <td width="47%"><u></u></td> 
         </tr> 
         {section name=skilldet loop=$skillCount} 
         <tr id="tr_{$skid[skillCount]}"> 
          <td><input type="text" name="skill[]" id="skillsnmusic" value="{$skill[skilldet]}" onfocus="javascript: $(this).siblings('.resumeTips').show();" onblur="javascript: $(this).siblings('.resumeTips').hide();"/> 
          <div id="resumeTips" class="colLeft resumeTips -hide" style="display: none;"> 
           <div id="tip-skills" class="tips tooltips"> 
            <div id="lbl-tip-skill" class="tipsSentence">Enter your skills (e.g. Project Management, Cost Accounting, C++, Oracle8).</div> 
            <div class="up-arrow-border"></div> 
            <div class="up-arrow"></div> 
           </div> 
          </div> 
          </td> 
          <td><select name="proficiency[]" id="proficiency"> 
            <option value=""></option> 
            {$proficiency[skilldet]} 
           </select> 
          </td> 
          <td><input type="text" name="certy[]" id="certy" value="{$certivalue[skilldet]}"/></td> 
          <td><a href="javascript:void(0)" id="tr_{$skid[skillCount]}" onclick='javascript: $(this).parent().parent().remove();'><img src="{$Templates_Image}remove.png" alt="" /></a> </td> 
         </tr> 
         {/section} 
        </tbody> 
       </table> 
        <table width="100%" cellspacing="0" cellpadding="3" border="0" class="skills" style="display:none;"> 
        <tbody> 
         <tr> 
          <td width="18%"><input type="text" name="skill[]" id="skillsnmusic" onfocus="javascript: $(this).siblings('.resumeTips').show();" onblur="javascript: $(this).siblings('.resumeTips').hide();"/> 
          <div id="resumeTips" class="resumeTips" style="display: none;"> 
           <div id="tip-skills" class="tips tooltips"> 
            <div id="lbl-tip-skill" class="tipsSentence">Enter your skills (e.g. Project Management, Cost Accounting, C++, Oracle8).</div> 
            <div class="up-arrow-border"></div> 
            <div class="up-arrow"></div> 
           </div> 
          </div> 
          </td> 
          <td width="13%"><select name="proficiency[]" id="proficiency"> 
            <option value=""></option> 
            {$proficiencyList} 
           </select> 
          </td> 
          <td width="22%"><input type="text" name="certy[]" id="certy" /></td> 
          <td width="47%"><a href="javascript:void(0)" onclick='javascript: $(this).parent().parent().parent().parent().remove();'><img src="{$Templates_Image}remove.png" alt="" /></a> </td> 
         </tr> 
        </tbody> 
       </table> 
       </div> 
       <div id="resumeTips" class="colLeft resumeTips -hide" style="display: none;"> 
        <div id="tip-skills" class="tips tooltips"> 
         <div id="lbl-tip-skill" class="tipsSentence">Enter your skills (e.g. Project Management, Cost Accounting, C++, Oracle8).</div> 
         <div class="up-arrow-border"></div> 
         <div class="up-arrow"></div> 
        </div> 
       </div> 
       <a href="javascript:void(0)" class="add-lang" onclick='javascript: $(".skills").clone().appendTo(".skillList").show().removeClass("skills");'><img src="{$Templates_Image}pls.png">Add Skill/Music</a> </div> 
     </div> 
     <div class="ttr-rg-title"> Upload Photo </div> 
     <div class="upload-photo-rg"> 
      <div class="upload-thumb"> <span>Current Photo</span> <img src="{$img_path}small_thumb_{$tutorData->photo}"> </div> 
      <div class="upload-photo-data"> <b>Upload a Photo</b> 
       <p>You can Upload a JPG, GIF or PNG file (File size limit is 4MB).</p> 
       <input type="file" name="photo" /><br><i>Please upload photo having minimum dimensions 120px X 140px (Width X Height).</i> 
       <input type="hidden" name="hidden_photo" value="{$tutorData->photo}" /> 
       <br> 
      </div> 
      <div class="clear"></div> 
      <p>We highly recommend you to upload your photo to increase your chance of getting assignments. If you do not have your photo ready, you can upload it later. Please upload only your personal photo.</p> 
     </div> 
     {if $flagUpdate} 
     <div class="clear"></div> 
     <div class="ttr-rg-title"> Resume Privacy Setting </div> 
     <div class="clear"></div> 
     <div class="bigtab-data"> 
      <ul class="priority-app-list"> 
       <li> 
        <input type="radio" name="searchable" value="1" {if $tutorData->searchable=="1"}checked{/if} /> 
        <div class="pal-data"> <b>Searchable with Contact Details </b> 
         <p> Allow Employers to search for my resume and see my name and contact details.</p> 
        </div> 
       </li> 
       <li> 
        <input type="radio" name="searchable" value="0" {if $tutorData->searchable=="0"}checked{/if} /> 
        <div class="pal-data"> <b>Not Searchable</b> 
         <p>Do not allow employers to search for my resume.</p> 
        </div> 
       </li> 
      </ul> 
     </div> 
     <div class="clear"></div> 
     <div class="ttr-rg-title"> Profile Notification </div> 
     <div class="clear"></div> 
     <div class="bigtab-data"> 
      <ul class="priority-app-list"> 
       <li> 
        <input type="radio" name="profile_notification" value="1" {if $tutorData->profile_notification=="1"}checked{/if} /> 
        <div class="pal-data"> <b>Receive Notification of Tuition Jobs via Text Messages </b> 
         <p> This enables you to get your preferred tuition jobs faster</p> 
        </div> 
       </li> 
       <li> 
        <input type="radio" name="profile_notification" value="0" {if $tutorData->profile_notification=="0"}checked{/if} /> 
        <div class="pal-data"> <b>Do not like to Receive Notification of Tuition Jobs via Text Messages</b> 
         <p>You will only get notification via emails or phone calls.</p> 
        </div> 
       </li> 
      </ul> 
     </div> 
     {/if} 
    </div> 



    <div class="clear"></div> 
    <div class="tutor-registration-form" style="width:100%; text-align:center;"> <br> 
     <input type="hidden" name="tutor_id" value="{$tutorData->tutor_id}" /> 
     <input type="hidden" name="flagUpdate" value="{$flagUpdate}" /> 
     <input type="hidden" name="from" value="{$backPage}" /> 
     <button type="submit" class="c-profile" name="submit" value="Update Profile" >Update Profile</button> 
     <hr> 
    </div> 
</form> 
{literal} 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $('#tabresults1').tabify(); 
     $('#tabresults').tabify(); 
    }); 

    // JavaScript Document 
$(document).ready(function() 
{ 
    $('#Loading_1').hide(); 
    $('#Loading_2').hide(); 
    $('#Loading_3').hide(); 
    $('#loader_1').hide(); 

    /*$('.languageList input[type="checkbox"]').on('change', function(e){ 
     if($(this).prop('checked')) 
     { alert('1'); 
      $(this).next().val(1); 
     } else { 
      $(this).next().val(0); 
     } 
    });*/ 
}); 

function checkUncheckLang(th) 
{ 
    if($(th).prop('checked')) 
    { 
     $(th).next().val(1); 
    } else { 
     $(th).next().val(0); 
    } 
} 

function checkUserEmail(value,rec){ 
//alert(val); 
    var username = $(value).val(); 

    if(username.length > 0){ 
     $('#Loading_'+rec).show(); 
     $.get(""+site_root+"check_availability.php", { 
      username: username, 
     }, function(response){ 
      $('#Info_'+rec).fadeOut(); 
      $('#Loading_'+rec).hide(); 
      var responseArray = response.split('###'); 
      if(responseArray[1] == '0') 
      { 
       value.value=''; 
      } 
      setTimeout("finishAjax('Info_"+rec+"', '"+escape(responseArray[0])+"')", 450); 
     }); 
     return false; 
    } 
} 
function finishAjax(id, response){ 
    $('#'+id).html(unescape(response)); 
    $('#'+id).fadeIn(1000); 
} 

$(function() { 
    //$("#birthdate").datepicker({ changeMonth: true, changeYear: true, maxDate: "-18Y", dateFormat: "yy-mm-dd"}); 
    $('#birthdate').combodate(); 
}); 

</script> 
{/literal} 
+1

选中复选框始终返回null。 – julekgwa

回答

0

首先,使用循环中选择生成选项,例如:

{foreach from=$arrNetworkDTO item=NetworkDTO} 
    <option value="{$NetworkDTO->name|escape}">{$NetworkDTO->name}</option> 
{/foreach} 

关于空值有人也有这样的问题:Checkbox array returning NULL

+0

有用,因为这可能,这不是一个问题的答案 – Martin

相关问题