-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.php
More file actions
73 lines (51 loc) · 1.48 KB
/
config.php
File metadata and controls
73 lines (51 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
date_default_timezone_set('Asia/Jakarta');
$host = 'localhost';
$user = 'root';
$pass = '';
$dbname = 'db_rekamedis';
$koneksi = mysqli_connect($host, $user, $pass, $dbname);
// if(!$koneksi){
// die('Koneksi gagal');
// } else {
// echo "Koneksi Berhasil !";
// }
$main_url = "http://localhost/MEDICAL_codingline/";
function uploadGbr($url){
$namafile = $_FILES['gambar']['name'];
$ukuran = $_FILES['gambar']['size'];
$tmp = $_FILES['gambar']['tmp_name'];
$ekstensiValid = ['jpg','jpeg','png','gif'];
$ekstensiFile = explode('.', $namafile);
$ekstensiFile = strtolower(end($ekstensiFile));
if(!in_array($ekstensiFile, $ekstensiValid)){
echo "<script>
alert('Input user gagal, file yang Anda upload bukan gambar !');
window.location = '$url';
</script>";
die();
}
if($ukuran > 1000000){
echo "<script>
alert('Input user gagal, maksimal ukuran gambar 1 MB !');
window.location = '$url';
</script>";
die();
}
$namafileBaru = time() . '-' . $namafile;
move_uploaded_file($tmp, '../asset/gambar/' . $namafileBaru);
return $namafileBaru;
}
function in_date($tgl){
$dd = substr($tgl, 8, 2);
$mm = substr($tgl, 5, 2);
$yy = substr($tgl, 0, 4);
return $dd . "-" . $mm . "-" . $yy;
}
function htgUmur($tgl_lahir){
$tglLahir = new DateTime($tgl_lahir);
$hariini = new DateTime("today");
$umur = $hariini -> diff($tglLahir) -> y;
return $umur . " tahun";
}
?>