我在WordPress网站主题函数.php中运行某些代码时遇到问题。
我创建了一个具有表单的页面,并且表单的action属性应该将数据提交到主题functions.php。>
在提交表单时,页面将重定向到functions.php文件,但不执行任何操作。
这里是表格的代码
<div>
<form name="formSenda" method="POST" action="../wp-content/themes/storefront/functions.php">
<input type="text" placeholder="name" id="nameSenda" name="nameSenda">
<input type="email" placeholder="emailSenda" id="emailSenda" name="emailSenda">
<input type="submit" value="Check" name="submitSenda">
</form>
</div>
这是functions.php中的代码
function inSenda(&$na,&$em){ $message = "Hi $na, is your email $em?"; $headers = "From Fly Gadgets \r\n"; mail($em, "Invoice", $message, $headers); echo "<script type='text/javascript'> document.location = 'categories'; </script>"; }; $nameSenda = $_POST['nameSenda']; $emailSenda = $_POST['emailSenda']; if(!empty($nameSenda) && !empty($emailSenda)){ inSenda($nameSenda, $emailSenda); }
感谢您的时间。
我在wordpress网站的主题functions.php中运行某些代码时遇到问题。我创建了一个具有表单的页面,该表单的action属性应该将数据提交到主题...
您可以使用AJAX请求执行此操作。