mirror of
https://github.com/dyzulk/raisen-app.git
synced 2026-01-26 13:22:00 +07:00
Update functions.php
This commit is contained in:
committed by
GitHub
parent
b1e71fde48
commit
726eb3ff61
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// koneksi ke database
|
// koneksi ke database
|
||||||
$conn = mysqli_connect("localhost", "root", "", "phpdasar", "3308");
|
$conn = mysqli_connect("localhost", "root", "", "raisenapp");
|
||||||
|
|
||||||
function ranID(){
|
function ranID(){
|
||||||
$prefix = "pel-";
|
$prefix = "pel-";
|
||||||
@@ -28,39 +28,6 @@ function getuser($id) {
|
|||||||
return $user;
|
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) {
|
function role_id($id) {
|
||||||
global $conn;
|
global $conn;
|
||||||
$table = "user";
|
$table = "user";
|
||||||
@@ -268,7 +235,7 @@ function registrasi($data) {
|
|||||||
function tambahPelanggan($data) {
|
function tambahPelanggan($data) {
|
||||||
global $conn;
|
global $conn;
|
||||||
|
|
||||||
$id = ranID();
|
$id = ranID();
|
||||||
$email = htmlspecialchars($data["email"]);
|
$email = htmlspecialchars($data["email"]);
|
||||||
$password = password_hash("123456", PASSWORD_DEFAULT);
|
$password = password_hash("123456", PASSWORD_DEFAULT);
|
||||||
$nama = htmlspecialchars($data["nama"]);
|
$nama = htmlspecialchars($data["nama"]);
|
||||||
@@ -276,7 +243,7 @@ function tambahPelanggan($data) {
|
|||||||
$image = "default.png";
|
$image = "default.png";
|
||||||
$role_id = 2;
|
$role_id = 2;
|
||||||
$is_active = 1;
|
$is_active = 1;
|
||||||
$date_created = time();
|
$date_created = time();
|
||||||
|
|
||||||
$query = "INSERT INTO user
|
$query = "INSERT INTO user
|
||||||
VALUES
|
VALUES
|
||||||
|
|||||||
Reference in New Issue
Block a user