表单的action属性保持空白时提交表单的位置?

时间:2013-07-16 13:22:09

标签: php forms smarty

我正在使用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。任何人都可以在这方面帮助我,并清除我的怀疑。提前谢谢。

2 个答案:

答案 0 :(得分:1)

如果您未提供action属性值,则浏览器会将表单提交到其呈现表单的同一页面。但是,此行为未记录rfc-1867

答案 1 :(得分:0)

如果表格中没有给出任何动作,则

同一页