<?php
$tahun = date('y');
  $bulan = date('m');
  $hari = date('d');
  $rand = rand(1, 9999);
  $char = "D";
  $newID = $char.sprintf($tahun).sprintf($bulan).sprintf($hari).sprintf("%04s", $rand);


  $cekid=mysqli_num_rows(mysqli_query($conn, "SELECT * FROM santri WHERE id_santri='$newID'"));
  ?>