我正在使用smarty模板。我從表單模板的Smarty代碼如下:當表單的action屬性保持空白時提交表單?
<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" > </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" > </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" > </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" > </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
<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" > </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" > </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"> </td>
</tr>
</table>
</td>
</tr>
<input type="hidden" name="user_subscription" id="user_subscription_lifetime" value="lifetime" />
{/if}
<tr>
<td height="10"> <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> </td>
{/if}
<td><input type="submit" name="submit" value="{$submit_value}" class="submit" /></td>
<td> </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" > </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</form>
當我點擊提交按鈕的形式被重定向到view_users.php
頁面。但是我沒有看到這個頁面在表單的action屬性中。然後我沒有得到這個表格如何重定向到view_users.php
。任何人都可以在這方面幫助我,並清除我的疑惑。提前致謝。
:那麼頁面在表單提交後如何被重定向到頁面view_users.ph? – PHPLover
..你是正確的,但是可能會有一些JS在某個地方在稍後階段改變動作指向'view_users.php' – naththedeveloper
檢查是否有任何提交處理程序在提交時會更改'form action'形成。 –