- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
不能一起工作?在 HTML 中-6ren"> 不能一起工作?在 HTML 中-如果我只使用这段代码 但我希望 name="send"也可以同时工作(在 isset($_POST['send']) 中)。但它不起作用。所以我可以为这两种情况做吗? 我需要同时下载数据并将数据发送到-6ren">
如果我只使用这段代码 <a href works >
但我希望 name="send"也可以同时工作(在 isset($_POST['send']) 中)。但它不起作用。所以我可以为这两种情况做吗?
我需要同时下载数据并将数据发送到数据库。
<a href="./users/assets/upload/file/<?php echo $result['product_file']; ?>">
<form method="POST" action=" ">
<div class="row" style="background-color: #8CC63F;">
<div class="col-lg-12 dw_text text-center">
<button type="submit" name="send" style="font-size: 30px;">FREE DOWNLOAD</button>
</div>
</form>
</a>
最佳答案
在提交表单之前,您需要更正您的 HTML。看起来您在按下“免费下载”按钮时正在调用 url
。
要更正 HTML,您可以直接使用链接的 url
作为表单的 action
(像这样)
<form method="POST" action="./users/assets/upload/file/<?php echo $result['product_file']; ?>">
<div class="row" style="background-color: #8CC63F;">
<div class="col-lg-12 dw_text text-center">
<button type="submit" name="send" style="font-size: 30px;">FREE DOWNLOAD</button>
</div>
</form>
或使用 jQuery(正如您在评论中提到的那样)将表单提交到相同的 url
。请参阅下面的示例,
$.ajax({
type: 'POST',
url: "./users/assets/upload/file/<?php echo $result['product_file']; ?>",
data: $(this).serialize(),
success: function(data) { }
});
为了保持上述ajax
提交中的url
整洁,可以将$result['product_file'];
作为隐藏字段在 HTML 中。因此,当我们按下“免费下载”按钮时,$(this).serialize()
也会序列化该值。因此,该 url 看起来与此类似,
url: "./users/assets/upload/file",
在 PHP 后端,product_file
的检索需要稍微修改以适应这一新变化。
希望对你有帮助
谢谢
关于php - <a> 和表单 <name =""> 不能一起工作?在 HTML 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53831279/
我是一名优秀的程序员,十分优秀!