Home » Wordpress » WordPress plugin form submiting

WordPress plugin form submiting

Posted by: admin November 30, 2017 Leave a comment


I have created a plugin for saving the reply me details. But whenever I submit the form using the plugin, it shows an error and it is redirected to some other page that shows ‘Not Found
Apologies, but the page you requested could not be found. Perhaps searching will help.” message. Please check my code

Plugin Name: Register Me
Plugin URI: http://demo.net
Description: Plugin is shows a simple Registration form
Author: Sumod Nair
Version: 1.0
Author URI: http://demo.net
add_action('init', 'reg_install');
function reg_install()
    global $wpdb;
    $table = $wpdb->prefix."reg_details";
    $structure = "CREATE TABLE $table (
        name VARCHAR(80) NOT NULL,
        place VARCHAR(20) NOT NULL,
        email VARCHAR(20) NOT NULL,
        mobno VARCHAR(20) NOT NULL,
        about_me VARCHAR(500) NOT NULL,
        date_apply datetime,
        UNIQUE KEY id (id)

add_shortcode('register', 'process_post');

function process_post(){
<form id="frmRegistration" name="frmRegistration" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>" method="POST">
<table style="align:center; width:500px; margin: 0 0 0 0;"> 
<td>Name </td>
<td><input type="text" name="name" id="name" maxlength="50" ><b><font color="red">*</font></b></td>
<td>Place </td>
<td><input type="text" name="place" id="place" maxlength="50" ><b><font color="red">*</font></b></td>
<td>Email </td>
<td><input type="text" name="email" id="email" maxlength="50" ><b><font color="red">*</font></b></td>
<td>Mobile No</td>
<td><input type="text" name="mobile_no" id="mobile_no" maxlength="50"><b><font color="red">*</font></b></td>
<td>About Yourself</td>
<td><textarea rows="4" cols="50" name="about" id="about" >

</textarea> <b><font color="red">*</font></b></td>
<td><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit Details" style="color:blue;"></td>
 <td align="right"><b><font color="red">*</font></b> fileds are mandatory</td></tr>

   global $wpdb;
    $table = $wpdb->prefix."reg_details";
 if(isset($_POST['btnSubmit'])) {
   // process $_POST data here
   $name = $_POST['name'];
   $place = $_POST['place'];
   $email = $_POST['email'];

   $mobile_no = $_POST['mobile_no'];
   $about_yourself = $_POST['about'];
   echo $name." " .$place." " .$email ." " .$mobile_no." " .$about_yourself;
  $wpdb->query("INSERT INTO $table(name, place,email,mobno,about_me,date_apply)
        VALUES('$name', '$place',' $email', '$mobile_no', '$about_yourself',now())");

Replace name="name" with something else, I’ve ran into exactly the same “bug”. To be sure, also replace other names with some unique string before it. E.g. name="frm-name", name="frm-mobile_no", etc.