D
D
dmplvtsv2015-10-27 13:01:29
Web development
dmplvtsv, 2015-10-27 13:01:29

How to pass data with post method between Wordpress pages?

I don’t understand how to send data between wordpress pages (created through the admin panel).
on the page site.ru/page1 there is a form that sends data to the page site.ru/page2. but the variables do not reach the second page

<form class="topbutton" method="post" action="/page2">
   <input type="hidden" name="gorod" value="название города" />
   <input class="submit" type="submit" name="submit" value="Заказать сейчас" />
</form>

<?php  if (!empty($_POST["gorod"]))
 {
 
 echo $_POST["gorod"];
 
 }
 else
 {
 echo "Переменная не дошли";
 } ?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2015-10-27
@dmplvtsv

rather you have a link structure with / at the end
and when you redirect to the correct POST address data is lost
try with action="/page2/"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question