<?php    
    require_once('../Connections/conn_ama.php'); 
    include("../../../../../../functions/functions.php");

   // echo  GetSQLValueString($_POST['msgbody'],"text")."<br>";
   echo  $_POST['cfh'];

    if ((isset($_POST['MM_email'])) && (isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "send-response-email")) {

        $cfh = $_POST['MM_cfh'];
        $to_email = $_POST['MM_email'];
        $subject = $_POST['subject'];
        $message = $_POST['msgbody'];
        $from = 'feedback@ama.gov.gh';
        $fromname = 'Accra Metropolitan Assembly';
        
        $headers = "MIME-Version: 1.0" . "\r\n"; 
        $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; 
 
        // Additional headers 
        $headers .= 'From: '.$fromname.'<'.$from.'>' . "\r\n"; 
       /*  $headers .= 'Cc: welcome@example.com' . "\r\n"; 
        $headers .= 'Bcc: welcome2@example.com' . "\r\n"; */ 

       /*  echo $to_email."<br>";
        echo $subject."<br>";
        echo $message."<br>"; */

        $mailsent = mail($to_email,$subject,$message,$headers);
        

        if($mailsent){
            $updateSQL = "UPDATE citizenfeedback SET status = 2 WHERE cfharsh = '".$cfh."'";

            $Result1 = mysqli_query($conn_ama, $updateSQL) or die(mysqli_error($conn_ama));
            
            if($Result1){
                echo "datasent";
            }
           
        }
        else{
            echo "notset";
        }
    }

?>