【发布时间】:2017-12-05 10:02:20
【问题描述】:
我在一个 HTML 页面中使用这个 HTML 代码:
<form method="post">
<div class="form-group">
<input type="text" class="form-control" name="username">
</div>
<div class="form-group">
<input type="password" class="form-control" name="password">
</div>
<input type="hidden" name="ref" value="post-ad.php"/>
<button type="submit" name="submit" id="submit" class="btn">S'identifier</button>
</form>
单击提交按钮时,此表单将执行哪个操作?我注意到它在此示例中执行名为"ref" 的输入值"post-ad.php" 或"index.php" 或"dashboard.php"。正常吗?!据我所知,action 属性是强制性的?
【问题讨论】:
-
如果没有
action属性,它将根据methodPOST/GET 到同一页面。action不是强制性的 -
stackoverflow.com/questions/1131781/… 如果没有 action 属性,则使用当前页面。您名为 ref 的字段就像普通输入一样,因此该值将在 $_POST['ref'] 中作为字符串提供。
标签: html