<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>
<?php

  if(!empty($_POST)){

      $smtp_server = $_POST['smtp_server'];  
      $smtp_user = $_POST['smtp_user'];  
      $smtp_password = $_POST['smtp_password'];
      $smtp_port = $_POST['smtp_port'];
 	  $smtp_secure = $_POST['smtp_secure'];
   
        

    $update = $dbh->prepare("UPDATE smtp_settings SET 
     smtp_server = '".$smtp_server."',
     smtp_user = '".$smtp_user."',
     smtp_password = '".$smtp_password."',
     smtp_port = '".$smtp_port."',
     smtp_secure = '".$smtp_secure."'
      WHERE id = 1 " );

      $update->execute();

      }
?>

<?php
$ayar = $dbh->query("SELECT * FROM smtp_settings WHERE id = 1 ", PDO::FETCH_ASSOC);
if ($ayar->rowCount()) {
    foreach ($ayar as $ayar) {
    }
}
?>
        <!-- Page Content-->
        <div class="page-content">
          <div class="container-fluid">
            <!-- Page-Title -->

            <form method="post" action="" enctype="multipart/form-data">
              
              <div class="row">
                <div class="col-sm-12">
                  <div class="page-title-box">
                    <div class="row">
                      <div class="col">
                        <h4 class="page-title">SMTP Ayarları</h4>
                        <ol class="breadcrumb">
                          <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li> 
                          <li class="breadcrumb-item active">SMTP Ayarları</li>
                        </ol>
                      </div><!--end col-->
                      <div class="col-auto align-self-center">
                        <button class="btn btn-primary" type="submit">
                          <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                          GÜNCELLE
                        </button> 
                      </div><!--end col-->  
                    </div><!--end row-->                                                              
                  </div><!--end page-title-box-->
                </div><!--end col-->
              </div><!--end row-->
              <!-- end page title end breadcrumb -->


              <div class="row">
                <div class="col-lg-12">
                  <div class="card">
                    <div class="card-header">
                      <h4 class="card-title">SMTP Ayarları</h4>
                      <p class="text-muted mb-0">Değerli kullanıcı, bu alan sayesinde kullanıcılara oto gidecek olan mail bilgilendirmeleri için smtp ayarlarını yapabilirsiniz.</p> 
                    </div><!--end card-header-->
                    <div class="card-body">
                      <div class="row">

                        <div class="col-xl-6"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">SMTP Sunucusu</label>
                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="smtp_server" value="<?=$ayar['smtp_server'];?>"> 
                          </div>
                        </div>

                        <div class="col-xl-6"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">SMTP Kullanıcı Maili</label>
                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="smtp_user" value="<?=$ayar['smtp_user'];?>"> 
                          </div>
                        </div>

                        <div class="col-xl-4"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">SMTP Şifresi </label>
                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="smtp_password" value="<?=$ayar['smtp_password'];?>"> 
                          </div>
                        </div>

                        <div class="col-xl-4"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">SMTP Port</label>
                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="smtp_port" value="<?=$ayar['smtp_port'];?>" > 
                          </div>
                        </div>

                        <div class="col-xl-4"> 
                          <div class="form-group">
                            <label for="exampleInputEmail1">SMTP Güvenlik</label>
                            <input type="text" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" name="smtp_secure" value="<?=$ayar['smtp_secure'];?>" > 
                          </div>
                        </div>

                      </div>
                       

                <br>    
                <button class="btn btn-primary btn-block" type="submit">
                  <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
                  GÜNCELLE
                </button>
              </form>                                           
            </div><!--end card-body-->
          </div><!--end card-->
        </div><!--end col-->


      </div><!--end row-->



    </div><!-- container -->

    <?php include 'inc/footer.php';?>

