<?php
// include to get database connection
include_once 'config/db.php';
try{
$a_id = "SELECT a.id FROM aluno a, utilizador u WHERE a.utilizador_id = u.id
AND u.nome =" . $_POST['nome'];
$prof = 1;
$query = "INSERT INTO classificacao(nota, semestre, dt_classif,
aluno_id, utilizador_id) VALUES (nota=:nota, semestre=:semestre, dt_classif=DEFAULT ,
aluno_id=:aluno_id, utilizador_id=:utilizador_id)";
$stmt = $con->prepare($query);
$stmt->bindParam(":nota", $_POST['nota']);
$stmt->bindParam(":semestre", $_POST['semestre']);
$stmt->bindParam(":aluno_id", $a_id);
$stmt->bindParam(":utilizador_id", $prof);
// execute the query
if($stmt->execute()){
echo "Product was created.";
}else{
echo "Unable to create product.";
}
}
catch(PDOException $exception){
echo "Error: " . $exception->getMessage();
}
?>
I'm creating a CRUD with jQuery and PHP and I'm almost sure the error is in this file, I cannot create data, and the echos "Product was created." and "Unabled to create product." are not displaying anywhere. I was wondering if you could help