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 can I reuse the code to capture a param in a URL and place in a value in a hidden form?
- Unreadable pagination
- 200 Rewrite blog post links
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to store data from multiple forms using ajax and php
- How to set a min number of words for a blog post
- How to use $query->set with post__in?
- Loop through categories and display posts title under each dropdown
- Get post id in a function when edit/add a post
- Ajax loaded form replaces form action with Ajax url
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- how do I get a specific post from a post with a subcategory in WP
- How to limit the number of forgot password reset attempts in WordPress?
- Automatically create child pages and grandchild pages when saving a (parent) page
- Custom search results page not working with empty search
- Modify HTML structure of fields in woocommerce checkout form
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Second transition_post_status hook fired instead of the first
- How to store post ID’s in cookie or session to display the same posts later
- Which hook/action will help me solve my problem?
- How can I add extra word in permalink when someone click download button?
- Open post-content in archive page in a Modal box with bootstrap
- Ajax call return 404
- How to pre populate a form field with a link of a current user’s author profile?
- Why Won’t My Inputs in a form with a Get method work together?
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- remove post that has no content
- Show success or error messages in Ajax response to WordPress custom registration form
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Styling my own password protected page, how to deal with wrong password?
- Post repeating with infinite scroll
- Contact form won’t submit
- wp_mail file attachment not being placed in upload folder?
- Custom posts in different columns style
- Get children post mime type using parent post_ID wp_post
- Search Query: how to construct a search string from two select elements?
- How to show only subcategories in parent category not parent category?
- Login to wordpress by clicking a link and specifying usernaname and password in url
- 404 error when I acess the second page of post-type
- Databases – Submitting data from inputs to database [closed]
- How to show a ‘correct’ message after submit a form?
- db converts decimal number wrong
- Form Security: nonce vs. jQuery
- WordPress admin-ajax.php 400 bad request
- Which PHP page is the Default Posts Page
- retrieve post data and insert it in seperate static html page without WordPress
- Ajax contact form return 0
- Trying do build a contact form
- “operation successful” message
- WP Insert Post and then go to post
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- Returning data instead of echoing/printing
- User register hook is not working in woocomerce register form
- Display related posts without a plugin
- Search WordPress using static html page
- Counting Search results, and displaying the offset per page
- Count posts on multisite with blog id
- Function works everywhere, how to keep it to execute when creating a new post
- Making (and edit existing) posts with ID included
- Copy taxonomy terms from one post to another programmatically
- How to execute html code inside php?
- Parsing Menu Items and Blog Posts
- Pagination on Custom Post
- $wpdb returns duplicate posts
- How to avoid duplicates when creating recent network posts
- How to show an entire post content and not also the excerpt?
- Get latest post from all categories except one
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Update post title from external file?
- Parse error: syntax error, unexpected end of file
- How to put a form with php code into a variable or shortcode?
- Can a page contain php code?
- How to send form data from WordPress (Meta Box) to an OData service?
- Automatically add images to a menu
- Why is a wp function used in current PHP namespace’s callback not resolved to global scope?
- Load Posts on Click via Ajax into a DIV
- How to catch wordpress post ID when it’s published
- set post limit at load more ajax wordpress
- WordPress query undefined offset in loop
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- WordPress shortcode returns the data before
- Find Site ID From WP_Post
- WP_Query: getting posts where custom field exists
- Shortcode to embed Edit Account form not working
- Form Submission Not Working In Custom Theme
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Capture form data in one function and use it in another function (same file)
- Only show first image in foreach loop