-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_user.php
More file actions
26 lines (24 loc) · 733 Bytes
/
Copy pathdata_user.php
File metadata and controls
26 lines (24 loc) · 733 Bytes
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
<?php
if($username==''){
//belum login
$id_user = '';
$is_login = '';
$id_role = 0;
$sebagai = 'Pengunjung';
$nama_lengkap = '';
$jumlah_item_keranjang = 0;
} else{
$s = "SELECT a.*,
(SELECT COUNT(1) FROM tb_keranjang WHERE id_user=a.id) jumlah_item_keranjang
FROM tb_user a WHERE a.username='$username'";
$q = mysqli_query($cn, $s) or die(mysqli_error($cn));
if(mysqli_num_rows($q)==0) die('Data username tidak ada');
$d = mysqli_fetch_assoc($q);
$id_user = $d['id'];
$is_login = 1;
$id_role = $d['id_role'];
$sebagai = $d['id_role']==2 ? 'Admin' : 'Pembeli';
$nama_lengkap = $d['nama_lengkap'];
$jumlah_item_keranjang = $d['jumlah_item_keranjang'];
}
?>