<?php
defined("BASEPATH") or exit("No direct access allowed");
?>
<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> Edit</li>
                      </ol>
                    </nav>

    
 <?php 

if (isset($_POST['ubah'])){
          
            $id = $_POST['id'] ;
            $p1 = mysqli_real_escape_string($con,$_POST['p1']);
            $p2 = mysqli_real_escape_string($con,$_POST['p2']);
            $p3 = mysqli_real_escape_string($con,$_POST['p3']);
            $p4 = mysqli_real_escape_string($con,$_POST['p4']);
            $p5 = mysqli_real_escape_string($con,$_POST['p5']);
            $p6 = mysqli_real_escape_string($con,$_POST['p6']);
            $p7 = mysqli_real_escape_string($con,$_POST['p7']);

            mysqli_query($con,"update emailsender set e1='$p1',e2='$p2',e3='$p3',e4='$p4',e5='$p5',e6='$p6',e7='$p7' where md5(id)='".$_GET['id']."'");
            
               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 Diubah
                </div> 
                ';
               
               echo "
               <div class='container'>
                 <form class='form-horizontal' role='form' action='index.php?page=emailsender' method='POST'>
                   <button type='submit' class='btn btn-primary'><span class='glyphicon glyphicon-log-out'></span> Kembali</button>
                 </form>
               </div> 
               
               <script>
        	        swal('Good Job','berhasil mengubah data email sender','success');
                </script>
            
            "
            
               ;
             
}
?>
   
 <?php 
    
      $tampil=mysqli_fetch_row(mysqli_query($con,"select * from emailsender where md5(id)='".$_GET['id']."'"));
      
      

   ?>   

<div class="card-body">            

    <div class="container">
      <form action="" method="POST">
            <input type="hidden" name="id" value="<?php echo $tampil['id']; ?>">
      <div class="container">
      <form action="" method="POST">
          <p><label>Nama Sender</label><input type="text" name="p5" class="form-control" value="<?php echo $tampil[5]; ?>" required></p>
        <p><label>Url Host</label><input type="text" name="p1" class="form-control" value="<?php echo $tampil[1]; ?>" required></p>
        <p><label>Nama Email </label><input type="text" name="p2" class="form-control" value="<?php echo $tampil[2]; ?>" required></p>
        <p><label>Password</label><input type="password" name="p3" class="form-control" value="<?php echo $tampil[3]; ?>" required></p>
        <p><label>Port</label><input type="text" name="p4" class="form-control" value="<?php echo $tampil[4]; ?>" required></p>
        <p><label>Email Refly To (Email Balasan)</label><input type="email" name="p6" class="form-control" value="<?php echo $tampil[6]; ?>">
        <i>Bisa pakai email yahoo atau gmail</i>
        <p><label>Username SMTP</label><input type="text" name="p7" class="form-control" value="<?php echo $tampil[7]; ?>">
        <i>Username SMTP jika anda menggunakan layanan Amazon SES</i>
        </p>
        <div class="form-group">
          <div class  ="col-sm-4">
            <button type="submit" class="btn btn-primary" name="ubah"><span class="glyphicon glyphicon-pencil"></span> Ubah Email Sender</button>
          </div>
        </div>
      </form>
    </div>
</div></div>
    