<?php
session_start();
require'Database.php';
$database = new Database;
if(!$_SESSION['username']){
	header('Location: ../index.php');
	die();
}else{



?>	
<!DOCTYPE html>
<html lang="en">
  <?php include'head.php'; ?>
  <body class="app sidebar-mini rtl">
    <!-- Navbar-->
    <?php include'topnav.php'; ?>
    <!-- Sidebar menu-->
    <div class="app-sidebar__overlay" data-toggle="sidebar"></div>
    <?php include'nav.php'; ?>
    <main class="app-content">
      
        <div class="clearfix"></div>
        <div class="col-md-12">
          <div class="tile">
            <h3 class="tile-title">Send Email Portal</h3>
            <div class="table-responsive">
                <form action="send.php" method="post">
                            <div class="row">
                                    <div class="col-md-12 col-sm-12">
                                        <div class="form-group">
                                            <label for="firstName1">
                                                User Email Address
                                                <span class="danger">
                                                    *
                                                </span>
                                            </label>
                                            <input class="form-control required" id="firstName1" placeholder="User Email Address"
                                                type="email" name="accname">
                                        </div>
                                    </div>

                                </div>

         <div class="row">
                                    <div class="col-md-12 col-sm-12">
                                        <div class="form-group">
                                            <label for="firstName1">
                                                Email Title
                                                <span class="danger">
                                                    *
                                                </span>
                                            </label>
                                            <input class="form-control required" id="firstName1" placeholder="Email Subject"
                                                type="text" name="etitle">
                                        </div>
                                    </div>

                                </div>
                                <div class="row">
                                    <div class="col-md-12 col-sm-12">
                                        <div class="form-group">
                                            <label for="paddress">
                                                Email Header/ Caption
                                                <span class="danger">
                                                    *
                                                </span>
                                            </label>
                                            <input class="form-control required" id="paddress" name="eheader"
                                                placeholder="Email Header/ Caption">
                                        </div>
                                    </div>

                                </div>
                                <div class="row">
                                    <div class="col-md-12 col-sm-12">
                                        <div class="form-group">
                                            <label for="dob">
                                                Email Body
                                            </label>
                                            <span class="danger">
                                                    *
                                                </span>
                                            <textarea class="form-control" id="dob" name="ebody"></textarea>
                                        </div>
                                    </div>
                                </div>
                    
                 <button class="btn btn" name="submit">Send Email</button>
                </tbody>
                  </form>
              </table>
            </div>
          </div>
          <?php
    

if(isset($_POST["submit"])){
    $etitle = $_POST['etitle'];
    $eheader = $_POST['eheader'];
    $ebody = $_POST['ebody'];
    $accname = $_POST['accname'];
  
 

            //Send Email
            $from = "support@Airsuitlogcompany.com";
            $to = "$accname";
            $subject = "$etitle";
            $message = "<center><h5><span style='color:black;'>From:</span>Wideservicein'ldelivery <br><span style='color:black;'>To: </span>$accname</h5></center>";
            $headers = "From:" .$from . "\r\n";
            $headers .= "MIME-Version: 1.0" . "\r\n";
            $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
            $headers .= "<center><h3>$eheader</h3></center>" . "\r\n";
            $headers .= "<br><br><h4 style='text-align:justify; color:black;'>$ebody</h4>" . "\r\n";
            
            
          
            mail($to,$subject,$message,$headers);     
            echo "<font color='green'><b>Email was sent successful<b></font>";          
        }


          ?>
            
        </div>
        </div>
    </main>
    <!-- Essential javascripts for application to work-->
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/main.js"></script>
    <!-- The javascript plugin to display page loading on top-->
    <script src="js/plugins/pace.min.js"></script>
    <!-- Page specific javascripts-->
    <!-- Google analytics script-->
    <script type="text/javascript">
      if(document.location.hostname == 'pratikborsadiya.in') {
      	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      	m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      	})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
      	ga('create', 'UA-72504830-1', 'auto');
      	ga('send', 'pageview');
      }
    </script>
  </body>
</html>
<?php
}
?>