Whenever I load my external PHP page (loadTextBox.php) my variable $verb_value is never being set (always hits the die line). Does this mean my JQuery $.post is not sending data correctly or my external PHP page is not receiving the data correctly? Any ideas how I can fix this issue? I understand this is prone to SQL injection, but I will focus on that later by using a whitelist.
Main index page snippet:
function loadDoc()
{
$(document).on('change', '#verb', function()
{
var val = this.value;
$.post("loadTextBox.php", {verb_value: val}, function(data)
{
$("#textbox").val(data.first);
$("#textbox2").val(data.second);
$("#textbox3").val(data.third);
$("#textbox4").val(data.fourth);
$("#textbox5").val(data.fifth);
$("#textbox6").val(data.sixth);
}, "json");
});
}
loadTextBox.php snippet:
$file_absolute = "---Placeholder for correct file path---";
include_once($file_absolute);
$mysql = new mysqli($db_host, $db_username, $db_password, $db_name);
$verb_value = $_POST["verb_value"];
if(!$verb_value)
die("The value was not set");
The solution is very simple. Changing the word “change” to “click” allows everything to function correctly.