我有一张表格:
<form name="customer_details" method="POST" onsubmit="return form_validation()"
action="../customer-details.php">
我将PHP文件放在我的主题文件夹中,但WordPress给了我一个错误:404-真想不到在这里见到你!
我有一张表格:
<form name="customer_details" method="POST" onsubmit="return form_validation()"
action="../customer-details.php">
我将PHP文件放在我的主题文件夹中,但WordPress给了我一个错误:404-真想不到在这里见到你!
您只需在函数文件中定义一个动作方法,并将表单动作留空即可。
通过使用钩子初始化
add_action(\'init\',formaction);
function formaction() {
if($_post[\'submit\']==\'1\') {
//form submit code here
}
}
在表单中添加唯一字段。
Eg: <input type="hidden" name="wdm_action" value="1">
把你的\'customer-details.php\'
以下函数中的文件代码:- add_action(\'template_redirect\',\'wdm_customer_details\'){
//check if that field present in the form, if yes then perform the action
if(isset($_POST[\'wdm_action\'] && $_POST[\'wdm_action\'] != \'\'){
//customer-details.php file code
}
}
你应该改变这个(如果你不使用它php
直接归档,如示例所示。com/客户详细信息。php`):
action="../customer-details.php"
至action=""
相反,您应该将其用作page template
, 然后更改为:action="example.com/pagename"
我试图在WordPress中使用AJAX验证并提交表单,但是,我得到的响应是0。根据the codex, 这似乎表明admin ajax无法找到我定义的函数。我做错了什么?代码(为了演示而简化)<script type="text/javascript"> jQuery(function() { jQuery(document).on(\'click\', \'#test-button\', function() {