Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { echo json_encode(['status'=>'error']); exit(); }
|
||||
require_once 'db_config.php';
|
||||
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$username = trim($data['username'] ?? '');
|
||||
$nama = trim($data['nama_lengkap'] ?? '');
|
||||
|
||||
if (!$username || !$nama) {
|
||||
echo json_encode(['status'=>'error','message'=>'Data tidak valid']);
|
||||
exit();
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare("UPDATE users SET nama_lengkap=? WHERE username=?");
|
||||
$stmt->bind_param('ss', $nama, $username);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status'=>'success','message'=>'Profil berhasil diperbarui']);
|
||||
} else {
|
||||
echo json_encode(['status'=>'error','message'=>'Gagal memperbarui profil']);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user