-
Notifications
You must be signed in to change notification settings - Fork 2
/
kasir_update.php
71 lines (69 loc) · 2.08 KB
/
kasir_update.php
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
<?php
include("sess_check.php");
// query database memperbarui data pada database
if(isset($_POST['perbarui'])) {
$id=$_POST['kas'];
$nama=$_POST['nama'];
$user=$_POST['user'];
$userlama=$_POST['userlama'];
$telp=$_POST['telp'];
$pass=$_POST['password'];
$cekfoto=$_FILES["foto"]["name"];
$pass=$_POST['password'];
$namafoto = date('mdYHis');
if($user!=$userlama){
$sqlcek = "SELECT * FROM kasir WHERE user_kasir='$user'";
$ress = mysqli_query($conn, $sqlcek);
$rows = mysqli_num_rows($ress);
if($rows<1){
if($cekfoto!=""){
$foto=substr($_FILES["foto"]["name"],-5);
$newfoto = $namafoto.$foto;
move_uploaded_file($_FILES["foto"]["tmp_name"],"foto/".$newfoto);
$sql = "UPDATE kasir SET
nama_kasir='". $nama ."',
telp_kasir='". $telp ."',
user_kasir='". $user ."',
pass_kasir='". $pass ."',
foto_kasir='". $newfoto ."'
WHERE id_kasir='". $id ."'";
$ress = mysqli_query($conn, $sql);
header("location: kasir.php?act=update&msg=success");
}else{
$sql = "UPDATE kasir SET
nama_kasir='". $nama ."',
telp_kasir='". $telp ."',
user_kasir='". $user ."',
pass_kasir='". $pass ."'
WHERE id_kasir='". $id ."'";
$ress = mysqli_query($conn, $sql);
header("location: kasir.php?act=update&msg=success");
}
}else{
header("location: kasir_edit.php?kas=$id&act=add&msg=double");
}
}else{
if($cekfoto!=""){
$foto=substr($_FILES["foto"]["name"],-5);
$newfoto = $namafoto.$foto;
move_uploaded_file($_FILES["foto"]["tmp_name"],"foto/".$newfoto);
$sql = "UPDATE kasir SET
nama_kasir='". $nama ."',
telp_kasir='". $telp ."',
pass_kasir='". $pass ."',
foto_kasir='". $newfoto ."'
WHERE id_kasir='". $id ."'";
$ress = mysqli_query($conn, $sql);
header("location: kasir.php?act=update&msg=success");
}else{
$sql = "UPDATE kasir SET
nama_kasir='". $nama ."',
telp_kasir='". $telp ."',
pass_kasir='". $pass ."'
WHERE id_kasir='". $id ."'";
$ress = mysqli_query($conn, $sql);
header("location: kasir.php?act=update&msg=success");
}
}
}
?>