I am working on a plugin and I create new table with plugin installation, table created successfully.
Now I want to add data in this new table. I create a form in “lsp_manage_foo.php” and write insert query in “lsp_manage_process.php”. When I click on submit button I got the error:
Not Found
The requested URL /lgs_pro/wp-admin/lsp_manage_process.php was not found on this server.
Apache/2.2.15 (CentOS) Server at 192.168.2.2 Port 80
and in address bar the link is like that:
http://192.168.2.2/lgs_pro/wp-admin/lsp_manage_process.php
What is the issue?
Here is my code:
lsp_manage_foo.php:
<form action="lsp_manage_process.php" method="post" name="lsp_add_foo">
<table width="100%" border="0" cellspacing="4" cellpadding="0">
<tr>
<td width="25%">
<label>
foo Name
</label>
</td>
<td width="58%">
<input type="text" name="lsp_add_foo" id="lsp_add_foo" value="">
</td>
<td width="10%" align="right">
<input type="submit" name="lsp_save_foo" value="Add Foo">
</td>
</tr>
</table>
</form>
lsp_manage_process.php:
<?php
global $wpdb;
$foo_add = $wpdb->prefix."lsp_foo";
$lsp_foo_name = stripslashes(strip_tags($_POST['lsp_add_foo']));
$foo_shortcode = str_replace(" ", "_", $lsp_foo_name);
$foo_shortcode = strtolower($foo_shortcode);
$foo_data = array(
'foo_name' => $lsp_foo_name,
'foo_shortcode' => $foo_shortcode
);
$foo_insert = $wpdb->insert($foo_add,$foo_data);
header("Location: lsp_manage_foo.php");
?>
Ok i find the solution of this issue by myself
In “lsp_manage_foo.php” file
And in “lsp_manage_process.php”
I use this line
because my $wpdb not working in this “lsp_manage_process.php”, so i require “config.php” and my $wpdb works perfectly.