Use this code
<?php
if(isset($_REQUEST['submit_btn']))
{
echo "<div>";
$name = $_POST["names"];
echo "</div>";
$ins="insert into tablename (fieldname)values('$name') ";
$conn->query($ins);
?>
<script>
alert('inserted successfully');
</script>
<?php
$sel="select * from tablename";
$r=$conn->query($sel);
while($u=$r->fetch_object())
{
echo $u->fieldname;
}
}
?>
<form action="" method="POST">
<input type="text" name="names" id="names">
<input type="submit" value="submit" name="submit_btn">
</form>
Hope this will help you
Related Posts:
- Handling error states with admin_post
- form $_post action value gets truncated after it passes through two forms
- WordPress Custom Form – Getting Query Vars, Weird Glitch?
- Post from front end form to post_meta
- Passed variable gets undefined variable error on insert on next page
- Dynamic form variables for post meta
- HOW TO Insert Existing PHP Code to WOrdPress
- Bulk data save in custom table
- How to insert PHP code in a WordPress Post
- Has anyone tried putting PHP ActiveRecord on WordPress?
- Creating wordpress user registration form
- Insert code when users come from an specific referer
- submit the form to same page
- How to display related posts from parent category
- Make custom field meta not display if there is not data in it
- How to migrate the posts from an old custom legacy blog to a new WordPress website?
- Ajax form submit within a Post Metabox
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- Upload Image in a WordPress page using PHP
- How can I use wp_query to show all product data using just the products ID?
- Trying to add attribute to my posts’ featured image
- My form action url is being prepended with a directory that does not exists
- Custom profile field with birthday. Troubles with
- Loop through categories and display posts title under each dropdown
- How to store post ID’s in cookie or session to display the same posts later
- Input data from email form not going to JSON file
- get post content of particular post by url
- Post repeating with infinite scroll
- How to show a ‘correct’ message after submit a form?
- db converts decimal number wrong
- Ajax contact form return 0
- “operation successful” message
- Count posts on multisite with blog id
- Making (and edit existing) posts with ID included
- Parsing Menu Items and Blog Posts
- Pagination on Custom Post
- $wpdb returns duplicate posts
- How to show an entire post content and not also the excerpt?
- How to put a form with php code into a variable or shortcode?
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- WordPress shortcode returns the data before
- Shortcode to embed Edit Account form not working
- Form Submission Not Working In Custom Theme
- Increment paged on WP_Query
- Capture form data in one function and use it in another function (same file)
- How do I add more options to the post-new.php page?
- Submitting a form, using Ajax, to run a SQL Select query based on user input from the form
- Modify main query before it run without pre_get_post
- .html end of URl affected to SEO?
- Get the id of all images in a post
- Four posts per row [closed]
- Update if post with specific title exists
- Need help removing […] after excerpt
- Pass important values server-side when processing form
- WPDB secure custom form
- WordPressUser Submission Form
- Testing a Form’s Zipcode Field with Regular Expressions to Determine WordPress Page Behaviour
- Pagination in single.php
- Cascading dropdown select search based on Parent Page & Child Page
- Advanced Query posts
- My Custom Post Type AJAX Query is Returning no posts – why?
- How to get post image caption by index
- I want it to detect the duplicate comment and give a warning on the same page
- Inside Array – “unidentified index” error with “prepare was called incorrectly” despite not calling the prepared statement with wordpress [closed]
- Is there anyway I can call the year once?
- PHP multiple forms, same page, isset($_POST[]) not working?
- “Class Not Found” in HTML Form Target PHP File that contains the class
- Check $post->ID against multiple values
- Don’t update modified post date when user add a product review or comment?
- Limit the number of characters/words in an excerpt for a related posts section
- Posts missing on author page
- Implement jQuery Smart wizard
- Closing Comments conditionally in comments.php
- How to center all text body in single.php at once?
- Having trouble with customizing blog posts on the home page
- How do I stop my form from adding code to current page URL instead of re-directing. Been stuck for days
- Related Posts: if there is no category use tags
- How do if all posts has this category ID then do this
- Getting error in sql query
- If input field has value Require another field – PHP
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- Unable to get Post Category Name and URL
- Dynamically Create Posts Via XML File
- Basic PHP question (displaying post title over thumbnail) [closed]
- Submitting my form to the database and then redirecting to payment site
- insert thumbnail image from php script
- Saving Post redirects to 404 page when php $_GET variable in post body
- Accessing values entered via form – try again
- Nonce fail after second submit attempt
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Using Nonce for my Form
- How to pass username into form that sends data to database
- How to customize posts in WordPress by using HTML and CSS?
- foreach all the post
- Blog Posts not sorted and pagination not adjusted after filtering some category
- WooCommerce: write featured image dimensions to custom fields in product’
- transition_post_status hook, works – but not if the post is new