I have some issue with the insertion of data from an AJAX POST Request into mysql data base.
When I look into the POST Network of my console of my AJAX request, I have:
question1 item2
question2 ["lion","cat"]
So my ajax request works. But I cannot insert those two elements into my SQL data base. And the echo("ok") is not displayed as well. It seems like nothing has been post. Could you please help me? Thank you.
Here is my code:
<?php
require 'inc/functions.php';
require_once 'inc/db.php';
logged_only();
if(!empty($_POST)){
echo("ok");
$user_username = $_SESSION['auth']->username;
$req = $pdo->prepare("INSERT INTO survey1 SET username = ?, question1=?, question2=?");
$req->execute(array($user_username),$_POST['question1'],$_POST['question2']);
}
?>