wordpressのバックエンドだけでなく、フロントエンドからカスタムテーブルにデータを挿入しようとしています。以下は私のコードです。バックエンドからデータを挿入すると機能しますが、フロントエンドから挿入しようとするとエラー404が発生します。
<?php
/*
Plugin Name: Custom Form
Description: Custom Plugin
Author: Bijay Luitel
*/
// Create the table if not exixts
?>
<style>
p {
display:block;
}
h3 {
height:20px;
padding:10px 5px;
}
</style>
<?php
//Short Codes
add_shortcode('form_bands','form_bands');
function form_bands(){
global $wpdb;
$this_page = $_SERVER['REQUEST_URI'];
$query1 = "SELECT * FROM grade";
$result1 = $wpdb->get_results($query1);
$query2 = "SELECT * FROM branch";
$result2 = $wpdb->get_results($query2);
if($_POST['action']==1 && $_POST['name'] != '' ){
$page_one_table = 'band';
$name =$_POST['name'];
$mailingAddress = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$email = $_POST['email'];
$url = $_POST['url'];
$telephone = $_POST['telephone'];
$gradeId = $_POST['grade'];
$branchId = $_POST['branch'];
$insertMe="INSERT INTO band ('Name', 'MailingAddress', 'City', 'State', 'Zip', 'Email', 'URL', 'Telephone', 'GradeID', 'BranchID') VALUES('$name', '$mailingAddress', '$city', '$state', '$zip', '$email', '$url', '$telephone', '$gradeId', '$branchId')";
$insert_page_one = $wpdb->query($insertMe);
//$insert_page_one = $wpdb->insert($page_one_table, $page_one_inputs);
$form_id = $wpdb->insert_id;
if($insert_page_one)
{
echo '<div id="successMsg" class="updated below-h2"><p>Operation Successful</p></div>';
}
else{
echo '<div id="successMsg" class="updated below-h2"><p>Error ! Recheck and tryagain.</p></div>';
}
}
elseif ($_POST['action']==1 && $_POST['name'] == ''){
echo '<div id="successMsg" class="updated below-h2"><p>Error ! Recheck and tryagain.</p></div>';
}
?>
<h2>Bands</h2>
<div class="postbox">
<form action="" method="post">
<div class="inside">
<table class="form-table">
<tr>
<th>Name :</th>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<th>Address :</th>
<td><input type="text" name="address" /></td>
</tr>
<tr>
<th>City :</th>
<td><input type="text" name="city" /></td>
</tr>
<tr>
<th>State :</th>
<td><input type="text" name="state" /></td>
</tr>
<tr>
<th>Zip :</th>
<td><input type="text" name="zip" /></td>
</tr>
<tr>
<th>Telephone :</th>
<td><input type="text" name="telephone" /></td>
</tr>
<tr>
<th>Email :</th>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<th>Url :</th>
<td><input type="text" name="url" /></td>
</tr>
<tr>
<th>Grade :</th>
<td><select name="grade">
<?php foreach($result1 as $row){
$value = $row->GradeID;
echo '<option value="'.$value.'">';
echo $row->Grade;
echo "</option>";
}?>
</select></td>
</tr>
<tr>
<th>Branch :</th>
<td><select name="branch">
<?php foreach($result2 as $row){
$value = $row->BranchID;
echo '<option value="'.$value.'">';
echo $row->Name;
echo "</option>";
}?>
</select></td>
</tr>
</table>
<p class="submit">
<input type="submit" name="add_form" class="button-primary" value="Submit" />
</p>
<input type="hidden" name="action" value="1" />
</form>
</div>
</div>
<?php
}
function myForm ()
{
add_menu_page('Forms', 'Forms', '','forms', '');
add_submenu_page("forms", "Bands", "Bands", 0, "Bands", "form_bands");
}
add_action('admin_menu','myForm');
どうすればこの問題を解決できますか? 私を助けてください