[英]How to pass form input to Wordpress page?
I've got a small but persistent issue on my WordPress website. 我的WordPress网站上存在一个小而持久的问题。
On my homepage I have a form: 在我的主页上有一个表格:
<form method='post' action='/test/' >
Input: <input type="text" name="input">
<input type="submit">
</form>
With this form I'm trying to pass and use the input
value on another page. 通过这种形式,我试图在另一页上传递和使用
input
值。
I believe action
should = 'test.php'
not /test/
( /test/
is the URL of a regular WordPress page). 我认为
action
应该= 'test.php'
而不是/test/
( /test/
是常规WordPress页面的URL)。 I can't seem to access any X.php
pages in the URL, as it 404's every time (excluding index.php
, which doesn't 404, instead it just redirects from domain.com/index.php
to domain.com
我似乎无法访问URL中的任何
X.php
页面,因为它每次都是404(不包括不是404的index.php
,而是仅从domain.com/index.php
重定向到domain.com
I've tried creating a new php template (which I can use as a page template to customize the /test/
page), but it still 404's if I try to use action = 'new-template.php'
in the form. 我尝试创建一个新的php模板(可以将其用作页面模板来自定义
/test/
页面),但是如果我尝试在表单中使用action = 'new-template.php'
,它仍然是404。
Any suggestions on how I can pass the form data to another page in this scenario? 关于在这种情况下如何将表单数据传递到另一个页面的任何建议?
I can give you a simple example, 我可以举一个简单的例子
1st create a template and assign it to page eg. 1创建一个模板,并将其分配给页面,例如 test123 // you can hide it from custom site map creation.
test123 //您可以在自定义站点地图创建中将其隐藏。
then you can call that page as form submit page 然后您可以将该页面称为表单提交页面
<form method='post' action='<?php bloginfo('url'); ?>/test123/' >
try this you can write your php code inside the template. 试试这个,您可以在模板中编写您的php代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.