I have written insertion program in php. here it is:
<?php
$conn = new mysqli('localhost', 'root', '','optimize_statusdb');
$email = $_POST['user_email'];
$m_id = $_POST['message_id'];
$t_id = $_POST['thread_id'];
$conn->query("INSERT INTO `trackid`(`user_email`, `message_id`, `thread_id`) VALUES ('$email',$m_id,$t_id)");
?>
Here is the ajax function through which I trying to post the data into mysql:
View.on("sent", function(event) {
// If the user doesn't want the email to be tracked, we do nothing.
if (window.hunter_tracking_activated == true) {
$.ajax({
type: "POST",
url: "http://localhost:90/track/track.php",
data: {
thread_id: event.threadID,
message_id: event.messageID,
user_email: sdk.User.getEmailAddress(),
token: token
},
dataType: "JSON"
});
countUsage();
chrome.storage.sync.set({ "last_tracked_email_date": Date.now() });
alert("hello");
}
});
});
}
I am trying to insert into the values from the data
field in the JSON from the ajax code
. But after running the program, when I am trying to see in the table I could not see any values getting inserted.
Kindly, suggested me how I can achieve this using my code. How I can insert the values through Ajax to my mysql DB?