<?php
session_start();
if (isset($_SESSION['logged']) && $_SESSION['logged'] == "1" && $_SESSION['role'] == "admin") {

require_once('../../assets/constants/config.php');

$smtp_host = $_POST['host'];
$smtp_user = $_POST['user'];
$smtp_pass = $_POST['pass'];
$smtp_port = $_POST['port'];
$smtp_secure = $_POST['secure'];


try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname;charset=utf8mb4;collation=utf8_general_ci;prefix=''", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

	
 
$stmt = $conn->prepare("UPDATE tbl_smtp SET smtp_host = :host, smtp_user= :suser, smtp_pass = :pass, smtp_port = :port, smtp_secure = :secure");

$stmt->bindParam(':host', $smtp_host);
$stmt->bindParam(':suser', $smtp_user);
$stmt->bindParam(':pass', $smtp_pass);
$stmt->bindParam(':port', $smtp_port);
$stmt->bindParam(':secure', $smtp_secure);
$stmt->execute();


$_SESSION['reply'] = "037";
header("location:../smtp");


					  
}catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}

}else{

header("location:../");

}

?>
