top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

How to create custom form and insert data using this form into database in Wordpress?

0 votes

I am trying to make a custom form and insert into the database but when I click submit nothing happens. Please help me. I did research and changed my code but still same result. I don't know why.

This is the code:

Template Name: Student
<?php echo "google";?>    

         global $wpdb;
                  'std', array(
                               'name' => $name,
                               'roll' => $roll,
                               'dept' => $dept
                               ) == false) wp_die('Database insertion failed');
          echo "<p>Database insertion successful</p>";  
else //else we didnt submit the form, so display the form
<form action="" method="post" id="addcourse">
<label> Student Name:<input type="text" 
name="aname" size="30" /></label>
<label> Roll:<input type="text" 
name="aroll" size="30" /></label>
<label> Department:<input type="text" name="adept" size="30" /></label>
<br />
<input type="Submit" id="addcoursesubmit" value="submit" />

<?php get_sidebar(); ?>
<?php get_footer(); ?>
posted May 19 by Ankana Guchait

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
0 votes

I have 4 tables from the first table, I took all data from the two columns and displayed it in the view. For each data, I have two text fields and the user is supposed to fill those data. Having filled data into the text field, how can I insert all the records into the second table using one form only?

0 votes

So basically I have been trying to make my permalinks look like this:


Rather than what has the potential to become this:


Users have the ability to create posts on the front end that are children of other posts. This can go on and on and I don't want the permalinks to be insanely long.

I was able to remove all parent post names from the permalink using the code below. However, this doesn't work if someone creates a post name that already exists.

I would like to be able to change the permalink to include the post id in it so this doesn't happen but I can't figure it out. I appreciate any help!

Here is the code:

function Recipes() {

$labels = array(
'name'                  => _x( 'Recipes', 'Post Type Recipes', 'recipes' ),
'singular_name'         => _x( 'Recipe', 'Post Type Singular Name', 'Recipe' ),
'menu_name'             => __( 'Recipes', 'recipes' ),
'name_admin_bar'        => __( 'Recipes', 'recipes' ),
'archives'              => __( 'Recipes Archives', 'recipes' ),
'parent_item_colon'     => __( 'Parent Recipe', 'recipes' ),
'all_items'             => __( 'All Recipes', 'recipes' ),
'add_new_item'          => __( 'Add New Recipe', 'recipes' ),
'add_new'               => __( 'Add Recipe', 'recipes' ),
'new_item'              => __( 'New Recipe', 'recipes' ),
'edit_item'             => __( 'Edit Recipe', 'recipes' ),
'update_item'           => __( 'Update Recipe', 'recipes' ),
'view_item'             => __( 'View Recipe', 'recipes' ),
'search_items'          => __( 'Search Recipes', 'recipes' ),
$args = array(
'label'                 => __( 'Recipes', 'Recipes' ),
'description'           => __( 'Recipes', 'recipes' ),
'labels'                => $labels,
'supports' => array(
'taxonomies'            => array( 'category', 'recipes-tag' ),
'hierarchical'          => true,
'public'                => true,
'show_ui'               => true,
'show_in_menu'          => true,
'menu_position'         => 5,
'menu_icon'         => 'dashicons-editor-ul',
'show_in_admin_bar'     => true,
'show_in_nav_menus'     => true,
'can_export'            => true,
'has_archive'           => true,
'exclude_from_search'   => false,
'publicly_queryable'    => true,
'capability_type'       => 'page',
'show_in_rest'       => true,
'rest_controller_class' => 'WP_REST_Posts_Controller',
'rewrite'               => array( 'slug' => 'recipes' ),

register_post_type( 'recipes', $args );



add_action( 'init', 'Recipes', 0 );

function bvt_recipes_flatten_hierarchies( $post_link, $post ) {
    if ( 'recipes' != $post->post_type ) {
        return $post_link;
    $uri = '';
    foreach ( $post->ancestors as $parent ) {
        $uri = get_post( $parent )->post_name . "/" . $uri;

    return str_replace( $uri, '', $post_link );
add_filter( 'post_type_link', 'bvt_recipes_flatten_hierarchies', 10, 2 );
0 votes

I am making a custom plugin for wordpress and i need to create a page in the admin menu. I already have a file called menu_list.php with the following code:

function jps_mail_list_page_entry() {
    __('JPS Mailing List'),
    'JPS Mailing List',
add_action('admin_menu', 'jps_mail_list_page_entry');

function jpsNews_mailing_list() {
    echo 'hello';

Now, in the plugin page i have this:

function jpsNews_activate_plugin() {

Its not working. How can i do it?

Useful Links with Similar Problem
Contact Us
+91 9880187415
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.