I tried everything and I'm losing my mind
function submitItem(){
textarea = $("#textarea").val();
status = $("#status").val();
category = $("#categories").val();
date = $("#date").val();
var ajaxReq = new XMLHttpRequest();
ajaxReq.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("message").innerHTML = this.responseText;
}
}
ajaxReq.open("POST","../php/addItem.php",true);
ajaxReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxReq.send("textarea="+textarea+"&category="+category+"&status="+status+"&date="+date);
}
AJAX REQUEST
<?php
session_start();
require("server.php");
$cnx = new mysqli($server_name,$server_username,$server_password,$db);
$category = $_POST["category"];
$item = $_POST["textarea"];
$date = $_POST["date"];
$status = $_POST["status"];
$userID = $_SESSION["userID"];
$searchForCategory = "SELECT * FROM categories where categoryname = \"".$category."\"";
$result = $cnx->query($searchForStatus);
$row = $result->num_rows;
echo $row;
?>
And I tried everything, when I put and actual name it's working fine. I echo-ed the $category to see if it's working and it's working fine. I have no idea what the error might be
var_dump($category);show?#categories?