<?php
require_once "config.php";
$host=$_POST['host'];
$port=$_POST['port'];
$uname=$_POST['uname'];
$pwd=$_POST['pwd'];


$sql="select * from smtp_details";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}
if($result=mysqli_fetch_array($query)){
    $sql="update smtp_details set host='".$host."',port='".$port."', uname='".$uname."',pwd='".$pwd."'";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}else{
    echo mysqli_affected_rows($con);

}
}else{





   $sql="insert into smtp_details(host,port,uname,pwd) values('".$host."',"
        . "'".$port."','".$uname."','".$pwd."')";
$query=mysqli_query($con,$sql);
if($query==false){
    die(mysqli_error($con));
}else{
    echo mysqli_affected_rows($con);
} 
}