<?php defined( 'ABSPATH' ) or die( 'No script kiddies please!' );

global $wpdb;
$menu_name = sanitize_text_field($_POST['wpfm_save_menu_name']);  
   $table_name = $wpdb->prefix . "wp_floating_menu_details";    
    $insert = $wpdb->query($wpdb->prepare
        ("INSERT INTO ".$table_name."
        	(menu_name)
        	   VALUES(%s)",
                	array(
                    $menu_name
	           )
            )
       );
        if($insert){
        $lastid = $wpdb->insert_id;
        $_SESSION['wpfmp_message'] = __( 'New Menu Has Been Successfully Added', 'wp-floating-menu-pro' );   
        wp_redirect( admin_url() . 'admin.php?page=wpfmp-admin&action=wpfmp-edit-menu&id='.$lastid);
            }
        else{
        $_SESSION['wpfmp_message'] = __( 'New Menu Couldnot be Created. Please Try Again.', 'wp-floating-menu-pro' );   
        wp_redirect( admin_url() . 'admin.php?page=wpfmp-add-menu' );
        }