From 2ecd0ee03cb7bab9d30a9f9ea2bfcb9bd0fd51de Mon Sep 17 00:00:00 2001 From: Haidar <16521522@mahasiswa.itb.ac.id> Date: Fri, 17 Nov 2023 14:34:18 +0700 Subject: [PATCH] feat: add register php fix --- api/auth/Register.php | 15 ++++++++------- api/profile/get_code.php | 19 +++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/api/auth/Register.php b/api/auth/Register.php index ec67b88..8ee647c 100644 --- a/api/auth/Register.php +++ b/api/auth/Register.php @@ -18,16 +18,17 @@ $conn = Database::getInstance(); $conn->begin_transaction(); -$sql = "INSERT INTO users (username, email, password) VALUES (?, ?, ?)"; +$query = "SELECT IFNULL(MAX(id), 0) + 1 AS next_user_id FROM users"; +$result = $conn->query($query); +$row = $result->fetch_assoc(); +$nextUserId = $row['next_user_id']; + +$sql = "INSERT INTO users (username, email, password, id) VALUES (?, ?, ?,?)"; $stmt = $conn->prepare($sql); -$stmt->bind_param("sss", $username, $email, $en_password); +$stmt->bind_param("ssss", $username, $email, $en_password, $nextUserId); if ($stmt->execute() === TRUE) { try { - $query = "SELECT IFNULL(MAX(id), 0) + 1 AS next_user_id FROM users"; - $result = $conn->query($query); - $row = $result->fetch_assoc(); - $nextUserId = $row['next_user_id']; $arg0 = $nextUserId; $arg1 = password_hash($password, PASSWORD_BCRYPT); @@ -41,7 +42,7 @@ if ($stmt->execute() === TRUE) { </Envelope>'; // echo $requestBody; $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, '192.168.6.193:8081/code'); + curl_setopt($curl, CURLOPT_URL, '10.97.51.237:8081/code'); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: text/xml; charset="utf-8"', diff --git a/api/profile/get_code.php b/api/profile/get_code.php index 3093e33..31133aa 100644 --- a/api/profile/get_code.php +++ b/api/profile/get_code.php @@ -10,17 +10,16 @@ $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $UserId = $row['id']; - // echo $UserId; $requestBody = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> - <Body> - <getCode xmlns="http://service.example.org/"> - <arg0 xmlns="">' . $UserId . '</arg0> - </getCode> - </Body> - </Envelope>'; - // echo $requestBody; - $curl = curl_init(); +<Body> +<getCode xmlns="http://service.example.org/"> +<arg0 xmlns="">' . $UserId . '</arg0> +</getCode> +</Body> +</Envelope>'; +// echo $requestBody; +$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, '10.97.51.237:8081/getCode'); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, [ @@ -40,4 +39,4 @@ $requestBody = '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> $value = (string) $returnValue[0]; echo $value; } - + -- GitLab