Good afternoon, I am trying to take the values of a field in a table with the clause where of a $ _POST that I bring from another page. The variable in question is id_stud that I bring it to me by POST perfectly ... in fact when I save it in the database it appears as saved, but the select has no way to work:
<?php
// Connexion à la base de données
include('bdd.php');
//echo $_POST['title'];
$id_stud = $_POST['id_stud'];
if (isset($_POST['title']) && isset($_POST['start']) && isset($_POST['end']) && isset($_POST['color'])){
$title = $_POST['title'];
$start = $_POST['start'];
$end = $_POST['end'];
$color = $_POST['color'];
$id_teach = $_POST['id_teach'];
$id_stud = $_POST['id_stud'];
$query = mysql_query("select * from student where student_id = '$id_stud'");
$row = mysql_fetch_array($query);
$name = $row['firstname'];
$lastn = $row['lastname'];
$nombre = $name." ".$lastn;
$sql = "INSERT INTO events(title, id_teach, is_stud, start, end, color) values ('$nombre', '$id_teach', '$id_stud', '$start', '$end', '$color')";
//$req = $bdd->prepare($sql);
//$req->execute();
echo $sql;
$query = $bdd->prepare( $sql );
if ($query == false) {
print_r($bdd->errorInfo());
die ('Erreur prepare');
}
$sth = $query->execute();
if ($sth == false) {
print_r($query->errorInfo());
die ('Erreur execute');
}
}
//header('Location: '.$_SERVER['HTTP_REFERER']);
?>