mirror of
https://github.com/dyzulk/raisen-app.git
synced 2026-01-26 05:15:29 +07:00
Update functions.php
This commit is contained in:
committed by
GitHub
parent
b1e71fde48
commit
726eb3ff61
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
// koneksi ke database
|
||||
$conn = mysqli_connect("localhost", "root", "", "phpdasar", "3308");
|
||||
$conn = mysqli_connect("localhost", "root", "", "raisenapp");
|
||||
|
||||
function ranID(){
|
||||
$prefix = "pel-";
|
||||
@@ -28,39 +28,6 @@ function getuser($id) {
|
||||
return $user;
|
||||
}
|
||||
|
||||
function getdata2($table, $id) {
|
||||
global $conn;
|
||||
|
||||
// Menggunakan prepared statement untuk mencegah SQL injection
|
||||
$stmt = mysqli_prepare($conn, "SELECT * FROM $table WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$data = mysqli_fetch_assoc($result);
|
||||
|
||||
// mysqli_close($conn);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function getuser2($id) {
|
||||
global $conn;
|
||||
$table = "user";
|
||||
|
||||
// Menggunakan prepared statement untuk mencegah SQL injection
|
||||
$stmt = mysqli_prepare($conn, "SELECT $id FROM user WHERE id = ?");
|
||||
mysqli_stmt_bind_param($stmt, "i", $id);
|
||||
mysqli_stmt_execute($stmt);
|
||||
|
||||
$result = mysqli_stmt_get_result($stmt);
|
||||
$data = mysqli_fetch_assoc($result);
|
||||
|
||||
// mysqli_close($conn);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function role_id($id) {
|
||||
global $conn;
|
||||
$table = "user";
|
||||
@@ -268,7 +235,7 @@ function registrasi($data) {
|
||||
function tambahPelanggan($data) {
|
||||
global $conn;
|
||||
|
||||
$id = ranID();
|
||||
$id = ranID();
|
||||
$email = htmlspecialchars($data["email"]);
|
||||
$password = password_hash("123456", PASSWORD_DEFAULT);
|
||||
$nama = htmlspecialchars($data["nama"]);
|
||||
@@ -276,7 +243,7 @@ function tambahPelanggan($data) {
|
||||
$image = "default.png";
|
||||
$role_id = 2;
|
||||
$is_active = 1;
|
||||
$date_created = time();
|
||||
$date_created = time();
|
||||
|
||||
$query = "INSERT INTO user
|
||||
VALUES
|
||||
@@ -291,4 +258,4 @@ function hapusPelanggan($id) {
|
||||
global $conn;
|
||||
mysqli_query($conn, "DELETE FROM user WHERE id = '$id'");
|
||||
return mysqli_affected_rows($conn);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user