require_once"konmysqli.php";
if(isset($_GET['sensor'])){
$sensor = $_GET['sensor'];
$status = $_GET['status'];
$tanggal = date("Y-m-d");
$jam = date("H:i:s");
$catatan = "";
$NF=date("YmdHis");
$gambar="img-$NF.jpg";
$file="C:\\Users\\USER\\Desktop\\IMGS\sent.jpg";
$newfile="C:\\xampp\\htdocs\\_PROJECT_FINAL\\arduino\\ap_ipcamera_keamanan\\ypathfile\\".$gambar;
if(!copy($file,$newfile)){
$catatan= "failed to copy $gambar";
}
else{
$catatan= "copied $gambar success\n";
}
$sql="INSERT INTO `$tblog`
(`kode_log`, `sensor`, `tanggal`, `jam`,`catatan`, `status`, `gambar`) VALUES
('', '$sensor', '$tanggal', '$jam', '$catatan', '$status', '$gambar')";
$simpan=process($conn,$sql);
//TELEGRAM
echo "sukses";
}
else{
echo "failed";
}
?>
<?php
function process($conn,$sql){
$s=false;
$conn->autocommit(FALSE);
try {
$rs = $conn->query($sql);
if($rs){
$conn->commit();
$last_inserted_id = $conn->insert_id;
$affected_rows = $conn->affected_rows;
$s=true;
}
}
catch (Exception $e) {
echo 'fail: ' . $e->getMessage();
$conn->rollback();
}
$conn->autocommit(TRUE);
return $s;
}
?>
Tidak ada komentar:
Posting Komentar