<?php
//global $wpdb;
/*
 Plugin Name:new plugin
 Description: A simple hello world wordpress plugin
Version: 1.0
Author: arti shrivas
Author URI: http://yourdomain.com
License: GPL
*/
/* This calls hello_world() function when wordpress initializes.*/
 //Note that the hello_world doesnt have brackets.

add_action('init','new_plugin');

function new_plugin()
{
//echo "Hello World";
global $wpdb;
$table_name ='wp_register';
if(isset($_POST['sub']))
{
   // echo "hello";

   $name=$_POST['name'];
   $dob=$_POST['dob'];
   $email=$_POST['email'];
  // echo $name." ".$dob." ".$email;



$wpdb->insert(  
    $table_name,  
    array(  
        'name' => $name,  
        'dob' => $dob,
        'email'=>$email
    ),  
    array(  
        '%s',  
        '%s',
        '%s'
    )  
); 

   //$wpdb->query("INSERT INTO $table_name (name, dob,email) VALUES('".$name."','".$dob."','".$email."')");
  // echo '<pre>';print_r($wpdb);  die;
}
if(is_page('132')){
?>
        <div class="new">
            <div class="new1">
                <form method="post" >
                        <?php //wp_nonce_field('update-options'); ?>

                       <lable>Your name</lable> <input type="text" name="name"><br/>
                       <lable>Date of birth</lable> <input type="text" name="dob"><br/>
                       <lable>Email id</lable><input type="text" name="email">                 
                        <br/>

                        <input type="submit" value="<?php _e('Save Changes') ?>" name="sub"/>
                </form>
            </div>
        </div>
<?php
}
}
?>

i am new to wp and i am try to create an simple registration plugin everythig is right but when i submit page it gives me a message
"This is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching can help."

what i am doing wrong plz help me
thanx in advance

Hey I have Done some modification hope this will work

<?php
/*
 Plugin Name:new plugin
 Description: A simple hello world wordpress plugin
Version: 1.0
Author: arti shrivas
Author URI: http://yourdomain.com
License: GPL
*/
/* This calls hello_world() function when wordpress initializes.*/
 //Note that the hello_world doesnt have brackets.

add_action('admin_menu', 'your_menu');
function your_menu() {
    add_menu_page('my_plugin', 'My Menu', 'manage_options', 'plug', 'new_plugin');
}


function new_plugin()
{
//echo "Hello World";
global $wpdb;
$table_name ='wp_register';
if(isset($_POST['sub']))
{
   // echo "hello";

   $name=$_POST['name'];
   $dob=$_POST['dob'];
   $email=$_POST['email'];
  // echo $name." ".$dob." ".$email;



$wpdb->insert(  
    $table_name,  
    array(  
        'name' => $name,  
        'dob' => $dob,
        'email'=>$email
    ),  
    array(  
        '%s',  
        '%s',
        '%s'
    )  
); 

   //$wpdb->query("INSERT INTO $table_name (name, dob,email) VALUES('".$name."','".$dob."','".$email."')");
  // echo '<pre>';print_r($wpdb);  die;
}

?>
        <div class="new">
            <div class="new1">
                <form method="post" >
                        <?php //wp_nonce_field('update-options'); ?>

                       <lable>Your name</lable> <input type="text" name="name"><br/>
                       <lable>Date of birth</lable> <input type="text" name="dob"><br/>
                       <lable>Email id</lable><input type="text" name="email">                 
                        <br/>

                        <input type="submit" value="<?php _e('Save Changes') ?>" name="sub"/>
                </form>
            </div>
        </div>
<?php

}
?>

@ code_rum thank you for replying i test your code and hope it will work

hey code_rum i tested your code but the problem is exists now what i can do for this i am creating a template also and on that template i am calling this plugin i will also post my template code for reference may be i done somthing wrong in template

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/new.css" />
<?php
/* template name:testing
 */

get_header(); ?>

    <div id="primary" class="site-content">
        <div id="content" role="main">
        <!-- this is plugin calling -->
            <?php
                if(function_exists('new_plugin')) {
                new_plugin();
                }
            ?>
            <?php //while ( have_posts() ) : the_post(); ?>
                <?php //get_template_part( 'content', 'page' ); ?>
                <?php //comments_template( '', true ); ?>
            <?php //endwhile; // end of the loop. ?>

        </div><!-- #content -->
    </div><!-- #primary -->

<?php get_sidebar(); ?>
<?php get_footer(); ?>

please tack a look on this also

I tried your code and everything is working fine.
I can see a form on admin side as well as on my template page.
Sorry if I am not getting what you want :(
Can you explain the output you want in short

@code_rum
when i am submit my form in fron and side then i get this message

This is somewhat embarrassing, isn’t it?

It seems we can’t find what you’re looking for. Perhaps searching can help.

i don't understand what i am doing wrong in code

you have not given action in your form.

<form method="post" action="page-you-want-to-redirect-to">

i am redirecting on the same page so no need to give action in tag.

Just change the value of name to anything like name="fname" and it gets solved

<lable>Your name</lable> <input type="text" name="fname"><br/>

May be this will work for you

thankyou to reply my problem is solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.