<?php
/**
 * Created by PhpStorm.
 * User: sunusi
 * Date: 2019-01-24
 * Time: 19:40
 */

session_start();

require_once getcwd() . "/../functions/db.class.php";
require_once getcwd() . "/../functions/form.data.php";
require_once getcwd() . "/../functions/robot.php";
require_once getcwd() . "/../functions/config.php";


if (isset($_POST["patientName"])) {

    $query = new db();
    /*
     * adding other information to the array
     */

    $_POST["userId"] = $_SESSION["YUZA_ID"];

    /*$condition = "`patientId` = '" . $_POST["patientId"] . "' ";
    $SQLPatients = SQLStmtUpdate("udut_patients", $_POST, $condition);*/

    $SQLPatients = "UPDATE udut_patients SET userId = '" . $_SESSION["YUZA_ID"] . "', patientName = '" . $_POST["patientName"] . "', patientEmail = '" . $_POST["patientEmail"] . "', patientPhone = '" . $_POST["patientPhone"] . "', patientDob = '" . $_POST["patientDob"] . "', patientAddress = '" . $_POST["patientAddress"] . "', patientGender = '" . $_POST["patientGender"] . "', patientCompanion = '" . $_POST["patientCompanion"] . "' WHERE `patientId` = '" . $_POST["patientId"] . "'   ";


    /*
     * Saving the patient details
     */
    $conn->query($SQLPatients) or die("Problem updating patients details " . $conn->error);


    header("location: ../about-patient/" . $_POST["patientId"]);

} else {
    header("location: ../add-patient");
}