" method="POST">

$ _POST returns empty on submit form in wordpress

I have a form:

<form action="<?php echo the_permalink(); ?>" method="POST"> <input type="text" name="name" value="" placeholder="Your First and Last Name *" /> <?php echo $firstnameError; ?> <input type="text" name="email" value="" placeholder="Yoyr Email" /> <?php echo $emailError; ?> <br> <input type="text" name="company" value="" placeholder="Your Company Name" /> <input type="text" name="phone" value="" placeholder="Your Phone number" /> <textarea name="project" rows="4" cols="50" placeholder="Describe the scope of work and the most important features of the project *'"></textarea> <?php echo $addressError; ?> <br> <input type="radio" name="budget" value="1500" /> <input type="radio" name="budget" value="2500" /> <input type="radio" name="budget" value="5000" /> <input type="radio" name="budget" value="10000" /> <input type="radio" name="budget" value="100001" /> <input type="radio" name="budget" value="not sure" /> <input type="hidden" name="submit" value="1" /> <input type="submit" value="SUbmit" /> </form> 

It works on one page, but when I do print_r($_POST); , it does not print anything, i.e. no value in $_POST .

What could be the reason for this? I studied a few questions about this, but no one gave me the answer I was looking for.

+4
source share
4 answers

If you pass the name as the value of Post, wordpress DOSNT like that!

change this value

 <input type="text" name="name" value="" placeholder="Your First and Last Name *" /> 

to

 <input type="text" name="thename" value="" placeholder="Your First and Last Name *" /> 

changing the name to thename , guaranteed to work !;)

+4
source

change this value

 acton="<?php echo the_permalink(); ?>" 

to

 action="<?php echo the_permalink(); ?>" 
+3
source
 <form action="<?php the_permalink(); ?>" method="POST"> 

You do not need the_permalink() echo.

This works for me:

 <?php print_r($_POST);?> <form action="" method="POST"> <input type="text" name="name" value="" placeholder="Your First and Last Name *" /><?php echo $firstnameError; ?><input type="text" name="email" value="" placeholder="Yoyr Email"/><?php echo $emailError; ?><br> <input type="text" name="company" value="" placeholder="Your Company Name"/><input type="text" name="phone" value="" placeholder="Your Phone number"/> <textarea name="project" rows="4" cols="50"placeholder="Describe the scope of work and the most important features of the project *'"></textarea><?php echo $addressError; ?><br> <input type="radio" name="budget" value="1500" /><input type="radio" name="budget" value="2500" /><input type="radio" name="budget" value="5000" /><input type="radio" name="budget" value="10000" /><input type="radio" name="budget" value="100001" /><input type="radio" name="budget" value="not sure" /> <input type="hidden" name="submit"value="1"/> <input type="submit" value="SUbmit" /> </form> 
+2
source

DECISION:

due to query issues on wordpress sites instead

 <form action="http://example.com/">... 

You may need to specify a .php file .. example:

 <form action="http://example.com/index.php">... 


////// ps echo is automatically performed using the_permalink() [same thing: echo get_permalink()

-3
source

All Articles