<?php
defined("BASEPATH") or exit("No direct access allowed");
if (isset($_POST['simpan'])){
if (!empty($_POST['e1']) && !empty($_POST['e2'])) {
	$e1 = mysqli_real_escape_string($con,$_POST['e1']);
	$e2 = mysqli_real_escape_string($con,$_POST['e2']);
	$e3 =  mysqli_real_escape_string($con,$_POST['e3']);
	$e4 = mysqli_real_escape_string($con,$_POST['e4']);
	$e5 = mysqli_real_escape_string($con,$_POST['e5']);
	$e6 = mysqli_real_escape_string($con,$_POST['e6']);
	$e7 = mysqli_real_escape_string($con,$_POST['e7']);

	mysqli_query($con,"INSERT INTO emailsender VALUE (NULL,'".$e1."','".$e2."','".$e3."','".$e4."','".$e5."','".$e6."','".$e7."')");
	//echo mysqli_error($con);
	//$idgrup = mysqli_insert_id($con);
	//$_SESSION['sesgrup'] = $idgrup;
	
	echo '
    	<!--	<div class="alert alert-success alert-dismissable" style="margin-top:20px">
                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                <h4><i class="icon glyphicon glyphicon-remove"></i> Data Berhasil Disimpan
                </div> -->
        
         <script>
        	        swal("Good Job","berhasil menyimpan data email sender","success");
                </script>        
                
                <script language="JavaScript">document.location="index.php?page=emailsender"</script>
                '
                ;

} else {
	
	echo "<div class='alert alert-warning alert-dismissable' style='margin-top:20px'>
            <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
            <h4><i class='icon glyphicon glyphicon-remove'></i> URL Host, nama Email, Password dan Port harus diisi
            </div>";
}

}
?>
<div class="card-header">
					
          <nav aria-label="breadcrumb">
                      <ol class="breadcrumb bg-warning text-white-all">
                        <li class="breadcrumb-item"><a href="#"><i class="fas fa-tachometer-alt"></i> Home</a></li>
                        <li class="breadcrumb-item"><a href="index.php?page=emailsender"><i class="far fa-file"></i> Email Sender</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><i class="fas fa-list"></i> Baru</li>
                      </ol>
                    </nav>
                    
          </div>
<div class="card-body">		  


<form action="" method="post">
<p><label>Nama Sender</label><input type="text" name="e5" maxlength="75" class="form-control" placeholder="Contoh: Admin" required/></p>
<p><label>Url Host (Outgoing Server)</label><input type="text" name="e1" maxlength="100" class="form-control" placeholder="Contoh: mail.yantonaim.web.id" required/></p>
<p><label>Nama Email</label><input type="text" name="e2" maxlength="150" class="form-control" placeholder="Contoh: demo@yantonaim.web.id" required/></p>
<p><label>Password Email Hosting</label><input type="password" placeholder="Contoh: X2019" name="e3" maxlength="75" class="form-control" required/></p>
<p><label>Port</label><input type="text" placeholder="Contoh: 465" name="e4" maxlength="4" class="form-control" required/></p>
<p><label>Email Refly To (Email Balasan)</label><input type="email" placeholder="Contoh: yantoit2011@yahoo.co.id" name="e6" maxlength="75" class="form-control"/><i>Bisa pakai email yahoo atau gmail</i></p>
<p><label>Username SMTP</label><input type="text" placeholder="Kosongkan jika tidak ada" name="e7" maxlength="75" class="form-control"/><i>Username SMTP jika anda menggunakan layanan Amazon SES </i></p>
<input class="btn btn-secondary btn-border" type="submit" name="simpan" value="Simpan Email Sender"/>
</form>
</div>