This commit is contained in:
Evelyn Sucitro 2025-11-18 09:59:01 +07:00
parent 05bc9c9f82
commit c0aeabdc50
6 changed files with 29 additions and 11 deletions

View File

@ -1,8 +1,8 @@
const BASE_URL = "http://localhost:3000/api"; const BASE_URL = "http://localhost/Kelompok06_2048";
export async function loginRequest(username, password) { export async function loginRequest(username, password) {
try { try {
const response = await fetch(`${BASE_URL}/login`, { const response = await fetch(`${BASE_URL}/Login.php`, {
method: "POST", method: "POST",
headers: { headers: {
"Content-Type": "application/json" "Content-Type": "application/json"

17
API Register.js Normal file
View File

@ -0,0 +1,17 @@
export async function registerRequest(username, password) {
const formData = new FormData();
formData.append("username", username);
formData.append("password", password);
try {
const response = await fetch(`${BASE_URL}/Register.php`, {
method: "POST",
body: formData
});
return await response.json();
} catch (err) {
console.error("API register error:", err);
throw err;
}
}

View File

@ -1,5 +1,5 @@
CREATE DATABASE IF NOT EXISTS 2048; CREATE DATABASE IF NOT EXISTS game_2048;
USE 2048; USE game_2048;
CREATE TABLE IF NOT EXISTS users ( CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY, id INT AUTO_INCREMENT PRIMARY KEY,

View File

@ -1,10 +1,11 @@
<?php <?php
$DB_HOST = ""; $DB_HOST = "202.46.28.160";
$DB_USER = ""; $DB_PORT = 23316;
$DB_PASS = ""; $DB_USER = "evelyn";
$DB_NAME = ""; $DB_PASS = "evelynsc25";
$DB_NAME = "web";
$conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME); $conn = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME, $DB_PORT);
if ($conn->connect_error) { if ($conn->connect_error) {
http_response_code(500); http_response_code(500);
die(json_encode(["status"=>"error","message"=>"Database connection failed"])); die(json_encode(["status"=>"error","message"=>"Database connection failed"]));

View File

@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
header('Content-Type: application/json'); header('Content-Type: application/json');
include 'Database.php'; include 'Koneksi.php';
$username = $_POST['username'] ?? ''; $username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? ''; $password = $_POST['password'] ?? '';

View File

@ -1,6 +1,6 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
include 'Database.php'; include 'Koneksi.php';
$username = $_POST['username'] ?? ''; $username = $_POST['username'] ?? '';
$password = $_POST['password'] ?? ''; $password = $_POST['password'] ?? '';