0

我正在使用 smarty 模板。我来自 smarty 模板的表单代码如下:

<form action="" name="manage_users" id="manage_users" method="post" >
    <input type="hidden" name="op" value="{$op}">
        <table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
        <tr>
          <td align="center">
            <table cellpadding="2" cellspacing="2" border="0">
            <tr>
                    <td colspan="2" align="center"></td>
                </tr>   
                {if $error_msg != ""}
                <tr>
                    <td align="center" class="errorMsg" colspan="2">{$error_msg.error_msgs}<br /></td>
                </tr>   
                {/if}
                {if $info_msg !="" && $error_msg==""}
                <tr>
                    <td align="center" class="success_msg" colspan="2">{$info_msg}<br /></td>
                </tr>   
                {/if}
        {if $site_id!='ENTPRM'}
                 {if $op == 'add' && $all_groups}
          <tr><td align="left"><label><b>{'Select Groups'|signal_on_error:$error_msg:'groups'}</b> <strong style="color:red">*</strong></label></td></tr>       
          <tr>
            {assign var='i' value=0}
                {foreach from=$all_groups item="group"}
                  {if $i%2 == 0}</tr><tr>{/if}
                    <td valign="top" align="left" width="200">
                      <table cellpadding="5" cellspacing="5" border="0">
                        <tr><td><input type="checkbox" name="parent_groups[]" id="{$group.parent_id}" onchange="check_subgroups(this.id, 'class_{$group.parent_id}'); return false;" value="{$group.parent_id}" {foreach from=$data.groups item=user_grp} {if $user_grp == $group.parent_id} checked="checked" {/if}{/foreach} ><b> {$group.parent_name} </b></td></tr>
                                                 <input type="hidden" name="main_groups[]" id="main_groups[]" value="{$group.parent_id}">
                          {foreach from=$group.subgroups item=subgroup}
                            <tr><td><input type="checkbox" name="groups_{$group.parent_id}[]" id="{$subgroup.group_id}" class="class_{$group.parent_id}" onchange="uncheck_main_group('{$group.parent_id}');" value="{$subgroup.group_id}" {foreach from=$data.groups item=user_grp} {$user_grp} {if $user_grp==$subgroup.group_id} checked="checked" {/if}{/foreach} style="margin-left:20px;"> {$subgroup.group_name}</td></tr>

                          {/foreach}
                      </table>  
                      {assign var='i' value=$i+1}
                    {/foreach}
                </td>
          </tr>
        {/if}  
        {/if}  
        <div id="add_more_user">        
        {if $op=='add' || $op=='edit'}
                <tr>
                    <td><label for="user_first_name"><b>{'First Name'|signal_on_error:$error_msg:'user_first_name'}</b> <strong style="color:red">*</strong></label><br>
          <input type="text" name="user_first_name" value="{$data.user_first_name}" class="inputfield" />
          </td>
                </tr>
        <tr>
           <td height="10" >&nbsp;</td>
              </tr>
        <tr>
                    <td><label for="user_last_name"><b>{'Last Name'|signal_on_error:$error_msg:'user_last_name'}</b> <strong style="color:red">*</strong></label><br>
          <input type="text" name="user_last_name" value="{$data.user_last_name}" class="inputfield" />
          </td>
                </tr>
        <tr>
           <td height="10" >&nbsp;</td>
              </tr>
        <tr>
                    <td><label for="user_dob"><b>{'Date Of Birth'|signal_on_error:$error_msg:'user_dob'}</b> <strong style="color:red">*</strong></label><br>
          <input type="text" name="user_dob" id="user_dob" value="{$data.user_dob}" class="inputfield" />
          </td>
                </tr>
        <tr>
           <td height="10" >&nbsp;</td>
              </tr>
        <tr>
                    <td><label for="user_email"><b>{'Email'|signal_on_error:$error_msg:'user_email'}</b> <strong style="color:red">*</strong></label><br>
          <input type="text" name="user_email" value="{$data.user_email}" class="inputfield" />
          </td>
                </tr>
         <tr>
           <td height="10" >&nbsp;</td>
              </tr>
                {/if}
        {if $op == 'add'}
          <tr>
            <td><label for="auto_username_pwd"> <b>Autogenerate User Password</b> <strong style="color:red">*</strong></label><br>
            <input type="radio" name="auto_username_pwd" id="auto_username_pwd_no" value="No" checked="checked" onchange="toggle_username_password(this.id);" onfocus="toggle_username_password(this.id);"/> No
            &nbsp;&nbsp;<input type="radio" name="auto_username_pwd" id="auto_username_pwd_yes" value="Yes" {if $data.auto_username_pwd =='Yes'} checked="checked" {/if} onchange="toggle_username_password(this.id);"  onfocus="toggle_username_password(this.id);"/> Yes
            </td>
          </tr>
           <tr>
             <td height="10" >&nbsp;</td>
          </tr>
          <tr>
            <td id='auto_username_password'  {if $data.auto_username_pwd=='Yes'} style="padding:0px; margin:0px;display:none;" {else} style="padding:0px; margin:0px;" {/if}>
              <table border="0" cellpadding="0" cellspacing="0">  
              <tr>
                <td><label for="user_password"><b>{'Password'|signal_on_error:$error_msg:'user_password'}</b> <strong style="color:red">*</strong></label><br>
                <input type="password" name="user_password" id="user_password" value="{$data.user_password}" class="inputfield"  maxlength="15" style="width:130px;"/>
                <br><I>(Use 6 to 15 characters)</I>
                </td>
              </tr>
              <tr>
                 <td height="10" >&nbsp;</td>
              </tr>
               <tr>
                <td><label for="retype_user_password"><b>{'Re-type Password'|signal_on_error:$error_msg:'retype_user_password'}</b> <strong style="color:red">*</strong></label><br>
                <input type="password" name="retype_user_password" id="retype_user_password" value="{$data.retype_user_password}" class="inputfield"  maxlength="15" style="width:130px;"/>
                <br><I>(Use 6 to 15 characters)</I>
                </td>
              </tr>
              <tr>
                <td height="10">&nbsp;</td>
              </tr>
              </table>
            </td>
          </tr>

        <input type="hidden" name="user_subscription" id="user_subscription_lifetime" value="lifetime" />
        {/if}           
            <tr>
          <td height="10">&nbsp;<input type="hidden" name="user_id" value="{$data.user_id}" /></td>
              </tr>
              </div>
                <tr>
                  <td align="center"><table cellpadding="0" cellspacing="0" border="0">
            <tr>
            {if $op=='add'}
              <td><input type="submit" name="submit" value="Add More" class="submit" /></td>
              <td>&nbsp;</td>
            {/if}
              <td><input type="submit" name="submit" value="{$submit_value}" class="submit" /></td>
              <td>&nbsp;</td>
              <td><input type="button" name="back" value="Back" class="submit" onclick="javascript:window.location.href='{$control_url}modules/users/view_users.php?op=view{if $user_name!=''}&user_name={$user_name}{/if}{if $user_email_id!=''}&user_email_id={$user_email_id}{/if}{if $user_group!=''}&user_group={$user_group}&{/if}{if $user_sub_group!=''}&user_sub_group={$user_sub_group}{/if}'" /></td>
            </tr>
            <tr>
                <td colspan="2" align="center" >&nbsp;</td>
            </tr>   
          </table></td>
                  </tr>
            </table></td>
        </tr>
      </table>
        </form>

当我单击提交按钮时,表单被重定向到页面view_users.php。但是我没有在表单的 action 属性中看到此页面。然后我不明白这个表单如何重定向到view_users.php. 任何人都可以在这方面帮助我并消除我的疑虑。提前致谢。

4

2 回答 2

1

当您不提供任何action属性值时,浏览器会将表单提交到与呈现表单的页面相同的页面。然而,这种行为没有记录在rfc-1867

于 2013-07-16T13:27:23.650 回答
0

如果表单中未给出任何操作,则显示同一页面

于 2013-07-16T13:22:28.927 回答