<?php
 
include 'dbconfig.php';
 
$custid = $_POST['custid'];
 
$custname = $_POST['custname'];
 
$nohp= $_POST['nohp'];

$alamat = $_POST['alamat'];

 
//$idno = $_POST['idno'];

 
 
 
// Create connection
 
$conn = mysqli_connect($servername, $username, $password, $dbname);
 
// Check connection
 
if (!$conn) {
 
    die("Connection failed: " . mysqli_connect_error());
 
}
 
/* grab the posts from the db */

/*
$query0 = "delete from TbCustomer where custid=".$custid;
$response2 = mysqli_query($conn, $query0) or die('Error query:  '.$query0);
 */

//  $query0 = mysqli_query($conn,"select * from TbCustomer where custname='".$custname."'");
//  $checkname=mysqli_num_rows($query0);
//  if ($checkname>0)
//  {
//     $result['errormsg']='exist';
//     $result['custname']=$custname;
//     echo json_encode($result);
//     return;
//  }

$query = "update TbCustomer set custname='$custname', nohp='$nohp',alamat='$alamat' where custid='$custid'";
 
/* 
if ($id != "0"){
 
$query = "update toko_profile set nama_toko='".$nama_toko."',alamat_toko='".$alamat_toko."',nohp='".$nohp."' ";
 
}*/
 
$response = mysqli_query($conn, $query) or die('Error query:  '.$query);
 
//$lid = mysqli_insert_id($conn);
 
$result["message"]="ok";
 
//$result["lid"]="$lid";
 
if ($response == 1){
 
    echo json_encode($result);
 
}
 
else{
 
    $result["message"]="failed";
 
    echo json_encode($result);
 
}
 
?>
