My issue that I encountered here is when I send a request with parameters to my PHP back-end it would act as a form was submitted and would send a false submission. I use AJAX to communicate with the front and back-end and the code I use is:
$(document).ready(function () {
$("#submitmsg").click(function () {
var usrmsg = $("#Text").val();
var username = localStorage.getItem("user")
$.post("send.php", { text: usrmsg,user: username,},
function(result){ });
$("#Text").val("");
return false;
});
});
in my backend where it gets the request is
$username = $_POST['user'];
$text = $_POST['text'];