I make a pop-up form like this, in home.php :
<script src="js/submit.js"></script>
.........
.........
.........
<div id="abc">
<!-- Popup Div Starts Here -->
<div id="popupContact">
<!-- Form -->
<form action="#" id="form" method="post" name="form">
<input id="month" name="month" placeholder="MONTH" type="text">
<a href="javascript:%20check_empty()" id="submit">ADD</a>
</form>
</div>
<!-- Popup Div Ends Here -->
</div>
I fill the form. When I click 'ADD' button, it runs javascript function. The code in submit.js :
function check_empty() {
if (document.getElementById('month').value == ""){
alert("Fill column!");
} else {
document.getElementById('form').submit();
$.get("application/insertdata.php");
return false;
}
}
//Function To Display Popup
function div_show() {
document.getElementById('abc').style.display = "block";
}
//Function to Hide Popup
function div_hide(){
document.getElementById('abc').style.display = "none";
}
I want to run query in insertdata.php as below. It needs the value from 'month'.
<?php
require("phpsqlajax_dbinfo.php");
$conn = mysqli_connect('localhost', $username, $password, $database);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$data = isset($_POST['month']);
$monthstring = mysqli_real_escape_string($conn, $data);
$sql = "INSERT INTO `databasea`.`tablea` (`MONTH`, `TEST`) VALUES ('". $monthstring ."', 'xxx');";
mysqli_query($conn, $sql);
mysqli_close($conn);
?>
The query run successfully, and row is added in my table. 'TEST' column is added with 'xxx'. But in 'MONTH' column, it generates no value, just empty.
So, how to get the 'month' value? Thank you.