// <?php

// require_once "config.php";

// header('Content-Type: application/json');
// $method = $_SERVER['REQUEST_METHOD'];

// switch ($method) {
//     case 'GET':
//         $query = $conn->query("SELECT cKodeCust, dtgllahir, cPassword FROM tbmember WHERE cPassword IS NULL OR cPassword = ''");
        
//         while ($row = $query->fetch_assoc()) {
//             $dtgllahir = $row['dtgllahir'];
//             $cKodeCust = $row['cKodeCust'];
            
            
//             if ($dtgllahir) {
//                 $formattedDate = formatDate($cKodeCust);
//                 $encodedPassword = encode($cKodeCust);

//                 $updateQuery = "UPDATE tbmember SET cPassword = ? WHERE cKodeCust = ?";
//                 $stmt = $conn->prepare($updateQuery);
//                 $stmt->bind_param("ss", $encodedPassword, $row['cKodeCust']);
//                 $stmt->execute();
//                 $stmt->close();
//             }
//         }

//         echo json_encode(['success' => 'Passwords updated successfully']);
//         break;
     
//     default:
//         http_response_code(405);
//         echo json_encode(['error' => 'Method not allowed']);
//         break;
// }

// mysqli_close($conn);

// function formatDate($date) {
//     $formattedDate = date("Ymd", strtotime($date));
//     return $formattedDate;
// }
