If 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>
Related Posts:
- add_filter the_content str_replace after shortcode
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Upload Image in a WordPress page using PHP
- My form action url is being prepended with a directory that does not exists
- Converting HTML Template to WordPress Theme
- Can I install/embed WordPress on a ‘single page’?
- How to store data from multiple forms using ajax and php
- Customize position of social icons in upme plugin [closed]
- Why Won’t My Inputs in a form with a Get method work together?
- Input data from email form not going to JSON file
- Login to wordpress by clicking a link and specifying usernaname and password in url
- How do I add a custom css to all posts without affecting homepage css? [closed]
- “operation successful” message
- Search WordPress using static html page
- How to execute html code inside php?
- Add data-id attribute to child page links
- How to add post meta in while loop?
- Adding attribute to the post.php form tag in wp-admin
- Make a page (url) not cacheable [closed]
- WordPressUser Submission Form
- Custom forms with HTML
- Cascading dropdown select search based on Parent Page & Child Page
- HTML Form Question
- Hide A Class and Add Custom HTML Code Using WordPress
- Trying to update Woocommerce meta values
- How to add a full working piece of website already coded, to a large scale Website design project?
- wordpress form action page not found
- Multisite – Display different header content based on which site is accessed
- Pass form attributes to another php template in wordpress
- Custom HTML form using PHP – help with ajax/username validation
- Code works on page-example.php by not category-example.php
- Save Option on Database
- HTML in PHP problem [closed]
- Add multiple HTML attributes to an Elementor button
- How to read if a checkbox is checked in PHP?
- Get author full name
- Why would a GET variable one one page of a site cause a 404 error when a GET variable works on another page of a site?
- Where should I install a PHP library into WordPress so that code in a webpage can activate it?
- load/require specific php files for specific pages/templates/post types
- WordPress Customizer: How can you have multiple active callbacks on one control?
- Edit postmeta when user changes user role?
- Minify HTML, CSS, JS with PHPWee?
- Add attribute / custom attribute to product in woocommerce
- Displaying theme options in css
- Hide wordpress field if data is empty in post!
- Custom Form Processing Issue
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- Change title only in dynamic page
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- A form that can save/edit after first input
- Output custom field value to post string
- Search Query: how to construct a search string from two select elements?
- Databases – Submitting data from inputs to database [closed]
- WordPress admin-ajax.php 400 bad request
- Custom Background by Page IDs
- Is this spyware on my site or a real Java update?
- Underscore – Self hosted fonts
- WordPress plug-in for dynamic download link?
- How to remove the h6 tag for the entry-category Class
- page-slug.php not working but only for specific slug
- Override user-edit.php to design own profile page
- Highlight the links without using dropdown
- How to turn each phone number within the $content to a telephone link?
- Creating custom page template from existing PHP site
- wordpress site – using custom database and PHP
- File Uploader – Upload without adding to Media Library
- Remove in post content
- Display movies that apear this day next
- Array data not saving to specified sections. How to make seting independantly?
- Display WordPress search results based on the selected Sub-Category
- Integrate otp in my custom singup form
- How do I call a value from the datase using ajax
- Fatal error login WordPress [duplicate]
- How to block specific user id in custom login form?
- Help me I cannot link my font-awesome to my WordPress Theme. I have my font-awesome folder already in my project
- How to use wp_ajax_set_post_thumbnail?
- Passing a value from an input field to a php function in WordPress?
- Comparison operator != not working in field [closed]
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Store user form submitted information in post type
- Problem with my Login Plugin
- How to return html as a string from php for WordPress
- Show subcategory name selected in specific category woocoommerce
- Unable to insert current username into custom table through html form
- Add custom attribute to product’s HTML to woocommerce cart page
- Splitting table data to pages with numbers
- Styling admin page rows in order of importance (checkboxes)
- nested divs, classes for a grid in loop [duplicate]
- featured post as div background
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Page template with custom html fields inside a content
- upload images on front by user using form
- Php echo into tag
- WP_Query not returning results
- How do I link the side images?
- How to create a container in php then customise it in CSS
- Redirect loop upon installation of my plugin
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- How to modify default tags in wp_head()