you should set the form action to custom_template.php
with this change, when the form is submitted, it will post the data back to the same page custom_template.php, and your PHP script will process the form data and display the entered name on the same page.
<table>
<form action="custom_template.php" method="POST"> <!-- Ensure form action is set to the same page -->
<tr>
<td> Name: </td><td><input type="text" name="name"></td>
</tr>
<tr>
<td><input value="Submit" type="submit" /></td></tr>
</form>
</table>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST["name"];
echo "<p>Name: $name</p>"; // Displaying the entered name
}
?>
Related Posts:
- What is the correct way to use WordPress functions outside WordPress files?
- WP-CLI – Selecting PHP version
- Hide php Notices in Dashboard
- Shortcode to insert
- WordPress new user / forgot password emails are broken
- How to get year, month and hour in WordPress?
- Calling a method from functions.php on a click of a button
- Want to separate sections of posts. Can you restart loop?
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Using Echo in ShortCode – Stuck
- How do I create comment-reply-button using element not
- Two posts in same div – WP loop
- Compare two meta key values against each other inside the get_posts array?
- Removing WordPress profile fields from non-admins
- WordPress menu deletes when trying to add a hook
- Issue with foreach on duplicate meta_key’s
- Why am I getting ERR_NAME_NOT_RESOLVED when I add a site to my multisite installation? [closed]
- How to display custom field on homepage
- Show custom field if it exists, and show different elements if it doesn’t
- Making Quote Plugin more efficient
- Different database query in function.php using mysqli
- How to show only a certain part of the entry title?
- Create shortcodes within foreach loop (using array)
- Programmatically add and remove woocommerce product category
- Get image’s size name from it’s dimension
- If Query In Sidebar
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- wp_enqueue_scripts leads to error
- Passing UTM Parameters To Modify Page In WordPress
- How can I get the values of my WordPress $wpdb query in Jquery?
- How create a Shortcode with hover and complex options
- WordPress SQL injection
- Adding wrapper elements in the_date() like in the_title()?
- Plugin Generate Unexpected output during activation
- Function returns text instead of html [closed]
- How can I display a div ONLY if it is not a certain term page
- Echo title attribute php
- PHP code for displaying WordPress posts in a static page not working
- WordPress hit memory limit but not from the server
- How to override url params with rewrite rules vars?
- how to serialize() mysql update data
- How to render a block from php template
- Output: “Array”
- How to add data to a custom field at the wp_users table?
- Calculate days between two custom field value dates
- form built dynamically with php, not submitting
- Post to WordPress from another Server via PHP
- How to make a cookie be on the whole site instead of being on a specific page/
- Child Theme’s Read More Text
- call a string/function from database
- Grabing default from cuztomizer php file instead of other php script
- Unset all main menu items except those with $menu_object->title == ‘x’
- Deleting records with AJAX, deleting records as I search
- Create ACF Checkbox to get all ACF Values from Parent Page
- How a HTML form can trigger a PHP function?
- Custom Login page, redirection and restrictions
- Display custom field value in woocommerce variable product via jQurey
- ACF Taxonomy field values not select in backend
- Passing Current User ID into SQL statement
- Load WordPress core but with specific plugins
- Dynamic “home” image and URL based on current folder
- Warning in WordPress for Declaration of SplitMenuWalker::walk($elements, $max_depth) [duplicate]
- How to output values from a loop into a javascript array
- Display child-page links in sidebar on both Parent Pages AND Child Pages
- custom post type column countdown
- Right way to display the_author_meta fields?
- Creating wordpress user registration form
- Add missing alt tag to featured images for “storefront” theme
- what’s the syntax for if the image exists get the image?
- Clone the “proceed to cart” button and place it above checkout on the cart page, but only appear display size is 320px
- Load admin bar without wp_head or wp_footer [duplicate]
- Highlight Single Page Ancestor
- Latest Post Thumbnail Alt Text Missing
- offset and max_num_pages in pagination gallery
- Passing link parameter values to form
- Processing forms with php to wordpress database
- Removing get_template_part in child theme
- How to connect database table to each registered wordpress user.
- Show results for multiple page-types
- how to remove sidebar from particular one page
- How to callback custom field text
- WP Query conflict on tag.php and category.php template
- Simple tree display of WordPress menu
- How to get the rating value of each comment
- How to recognize and remove malicious code on wordpress? [closed]
- WordPress WP_Query() Not working properly
- Product Category Page in Full Width
- After declaring woocommerce theme support products are no longer displayed
- Log in and Register link should disappear after a user log in successfully into the dashboard page
- Display all categories (with link) of custom post type – WordPress
- How to display inputted data in Ajax without button or click event
- How do I empty a specific meta_value for all users in PHP
- Import users and custom user meta from csv
- How to enable REST API on custom post type without Gutenberg?
- Creating a table via dbDelta
- wpbd to connect to a VPS mysql database
- PHP Warning: Attempt to read property “id” on null
- Uncaught Error: Undefined constant “WP_CONTENT_DIR”
- Programmatic replacement of Publish date with Modified date does not work outside the_content area
- Remove links to the comments section