send forget password

				
					if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // Retrieve POST data
    $userName = isset($_POST['userName']) ? $_POST['userName'] : null;
    $type = isset($_POST['type']) ? $_POST['type'] : null;
    $source = isset($_POST['source']) ? $_POST['source'] : null;

    // Check for required parameters
    if (!$userName || !$type || !$source) {
        echo json_encode(array('msgType' => 'error', 'msg' => 'Missing required parameters'));
        exit;
    }

    // Prepare data for POST request to wealthelite.in
    $postData = array(
        'userName' => $userName,
        'type' => $type,
        'source' => $source
    );

    // Initialize cURL for wealthelite.in
    $curl = curl_init();
    $url = 'https://wealthelite.in/Login/login/send-forget-password-otp';

    curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 30,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POSTFIELDS => http_build_query($postData),
        CURLOPT_HTTPHEADER => array(
            "cache-control: no-cache",
            "Content-Type: application/x-www-form-urlencoded"
        )
    ));

    // Execute the request and handle response
    $response = curl_exec($curl);
    $error = curl_error($curl);
    curl_close($curl);

    // Handle cURL error
    if ($error) {
        echo json_encode(array('msgType' => 'error', 'msg' => 'cURL Error: ' . $error));
        exit;
    }

    // Decode the response if it's JSON
    $responseData = json_decode($response, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        echo json_encode(array('msgType' => 'error', 'msg' => 'Invalid response format'));
        exit;
    }

    // Check the response for success
    if (isset($responseData['status']) && $responseData['status'] === 'success') {
        // Assuming the response has a status field indicating success
        echo json_encode(array('msgType' => 'success', 'msg' => 'Reset details sent successfully'));
    } else {
        // Handle the case where the response indicates failure
        $errorMessage = isset($responseData['msg']) ? $responseData['msg'] : 'An error occurred while processing your request.';
        echo json_encode(array('msgType' => 'error', 'msg' => $errorMessage));
    }
} else {
    echo json_encode(array('msgType' => 'error', 'msg' => 'Invalid access'));
}
				
			
Whatsapp whatsapp
Instagram instagram
Call Us phone
Linkedin linkedin
chat