从数据库php提取数据

header.php

<?php 
  include('../database_connection.php');

  session_start(); 

  if (!isset($_SESSION['Username_Psycho']) ) {

    header('location: ../login/login.php');
  }
  if (isset($_GET['logout'])) {
    session_destroy();
    unset($_SESSION['Username_Psycho']);
    header("location: ../login/login.php");
  }
?>

动作.php

<?php

//action.php
include('../header.php');
include('../database_connection.php');

if(isset($_POST["action"]))
{
    if($_POST["action"] == "insert")
    {


        $qry= " SELECT Id_Psycho
        FROM psychologue
        WHERE Username_Psycho ='".$_SESSION['Username_Psycho']."' ";
        $statement = $connect->prepare($qry);

        $query = "
        INSERT INTO dossiermdc (Evaluation,Traitment,Id_Psycho,id_Patient) VALUES ('".$_POST["first_name"]."', 
        '".$_POST["last_name"]."','".$qry."','4')
        ";


        $statement = $connect->prepare($query);
        $statement->execute();
        echo '<p>Data Inserted...</p>';
    }

I want to insert the id_PSYCHO in the table dossiermdc using the session so first i do the first query qry to fetch the id_PSYCHO but it not work please any help.

评论