Notice: Undefined index: submit in C:\xampp\htdocs\index.php on line 29
<?php
/**
* Plugin Name: Form Insert DB
* Plugin URI: http://solutionshint.com
* Description: Just Insert Data into Custom Form
* Version: 1.0
* Author: SolutionsHint
* Author URI: http://solutionshint.com
*/
function custom_form() {
?>
<form action ="<?php echo $_SERVER['REQUEST_URI']; ?>" method ="post">
<label for name=""> Name:</label><br>
<input type = "text" name = "name" id = "name" placeholder = "Enter Name">
<label for name=""> City:</label><br>
<input type = "text" name = "city" id = "city" placeholder = "Enter City">
<label > State:</label><br>
<input type = "text" name = "state" id = "state" placeholder = "Enter State">
<label> Age:</label><br>
<input type = "text" name = "age" id = "age" placeholder = "Enter Age">
<input type = "submit" name = "submit" value = "Insert">
</form
<?php
}
// add_shortcode('display', 'custom_form');
if($_POST['submit']) {
global $wpdb;
$table_name ='student';
$name = $_POST['name'];
$city = $_POST['city'];
$state = $_POST['state'];
$age = $_POST['age'];
$success = $wpdb->insert("student", array(
"name" => $name,
"city" => $city,
"state" => $state,
"age" => $age ,
));
if($success) {
echo ' Inserted successfully';
} else {
echo 'not';
}
}
?>
This is my code I m new to php and i m devloping a plugin that will save form data into the database But I m getting the error
Notice: Undefined index: submit in C:\xampp\htdocs\index.php on line 29