<?php
    // get the data base first
    include('db_conx.php');
    
    $subject = $db_conx->real_escape_string(trim($_POST['subject']));
    $name = $db_conx->real_escape_string(trim($_POST['name']));
    $email = $db_conx->real_escape_string(trim($_POST['email']));
    $message2 = $db_conx->real_escape_string(trim($_POST['message']));
    
    // time to send a mail

    $to = 'support@standardspringplc.com';

    // Subject
    $subject = 'Customer| Contact us';

    // Message
    $message = '
    <html>
    <head>
        <title>Customer Care contact us service</title>
    </head>

    <body>
    <img src = "https://standardspringplc.com/images/logo.png" style="height:100px;">
        <h3>CONTACT US  </h3>
     
        <p>This message was sent on the '.$current_time.',
        <br />
        Subject: '.$subject.' <br />
        Email : '.$email.' <br />
        Message: '.$message2.' </br >

    </body>
    </html>
    ';

    // To send HTML mail, the Content-type header must be set
    $headers[] = 'MIME-Version: 1.0';
    $headers[] = 'Content-type: text/html; charset=iso-8859-1';

    // Additional headers
    $headers[] = 'From: '.$email.' ';
    $headers[] = 'To: support@standardspringplc.com';


    //sending the mail 
    $mail = mail($to, $subject, $message, implode("\r\n", $headers));
    if($mail){
            echo "success";
    }else{
        echo "error";
    }

?>