admin管理员组文章数量:1122846
I have 10 or more input hidden in 10 or more pages with different values in Wordpress text editor and I want to get the value using $_POST in a custom page template.
How to do this? I tried to called the input hidden name in my custom page template but the value is not getting.
Text editor
<form method="POST">
<input type="hidden" name="segment" value="test"/>
</form>
Custom page template
$segment = isset($_POST['segment']) ? $_POST['segment'] : '';
I have 10 or more input hidden in 10 or more pages with different values in Wordpress text editor and I want to get the value using $_POST in a custom page template.
How to do this? I tried to called the input hidden name in my custom page template but the value is not getting.
Text editor
<form method="POST">
<input type="hidden" name="segment" value="test"/>
</form>
Custom page template
$segment = isset($_POST['segment']) ? $_POST['segment'] : '';
Share
Improve this question
edited Nov 2, 2016 at 5:23
jgraup
9,8543 gold badges32 silver badges69 bronze badges
asked Nov 2, 2016 at 5:09
User014019User014019
1533 silver badges13 bronze badges
1
|
1 Answer
Reset to default 0If you're not specifying a page, then you would access the $_POST
data on the same page as your form.
print_r( $_POST );
if ( isset( $_POST[ 'firstname' ] ) )
{
echo $_POST[ 'firstname' ] . ' ' . $_POST[ 'lastname' ];
wp_die();
}
else
{
?>
<form method="POST">
First name:<br>
<input type="text" name="firstname" value="Mickey"><br>
Last name:<br>
<input type="text" name="lastname" value="Mouse"><br><br>
<input type="submit" value="Submit">
</form>
<?php
wp_die();
}
If you want to access $_POST
data on another page, you would probably need to specify that in the action
attribute.
<form method="POST" action="your_page_name_here.php">
<input type="hidden" name="segment" value="test">
<input type="submit" value="Submit">
</form>
- http://www.w3schools.com/html/html_forms.asp
本文标签: phpHow to get the value of input hidden html from text editor to custom page template
版权声明:本文标题:php - How to get the value of input hidden html from text editor to custom page template? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282436a1926642.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<input>
tag does not use and does not need a closing slash in HTML and never has. – Rob Commented Sep 8, 2019 at 21:12