function signUpProfile()
{
    $rm = new Response_Methods();
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        $result = $rm->inValidServerMethod();
        return $result;
    }
    //Check request url is https or not
    if (!empty($_SERVER["HTTPS"])) {
        if ($_SERVER["HTTPS"] !== "off") {
            $username = $rm->cleanData(trim($_POST['username']));
            $password = $rm->cleanData(trim($_POST['password']));
            $email = trim($_POST['email']);
            $deviceId = trim($_POST['deviceId']);
            $petType = $rm->cleanData(trim($_POST['petType']));
            $petBio = $rm->cleanData(trim($_POST['petBio']));
            $petName = $rm->cleanData(trim($_POST['petName']));
            $petDob = trim($_POST['petDob']);
            $petSpecies = $rm->cleanData(trim($_POST['petSpecies']));
            $notifyEvents = $rm->cleanData(trim($_POST['notifyEvents']));
            $profileId = $rm->rand_str(16, 4);
            if ($username == "" || $password == "" || $email == "" || $petType == "" || $petBio == "" || $petName == "" || $petDob == "" || $petSpecies == "" || $notifyEvents == "") {
                $result = $rm->fields_validation();
                return $result;
            } else {
                $checkUser = $rm->checkUserValidation($username, 'user_name_f');
                $checkEmail = $rm->checkUserValidation($email, 'email_f');
                if ($checkUser == 0) {
                    $result = $rm->userExistJson();
                    return $result;
                }
                if ($checkEmail == 0) {
                    $result = $rm->emailExistJson();
                    return $result;
                }
                $status = 0;
                date_default_timezone_set('Asia/Calcutta');
                $createdDate = date('Y-m-d H:i:s');
                $getList = array();
                //preparing list and inserting values in user_details table
                $getInsertFieldValue['user_name_f'] = $username;
                $getInsertFieldValue['email_f'] = $email;
                $getInsertFieldValue['device_id_f'] = $deviceId;
                $getInsertFieldValue['profile_id_f'] = $profileId;
                $getInsertFieldValue['join_date_f'] = $createdDate;
                $getInsertFieldValue['pet_type_f'] = $petType;
                $getInsertFieldValue['pet_name_f'] = $petName;
                $getInsertFieldValue['pet_dob_f'] = $petDob;
                $getInsertFieldValue['description_f'] = $petBio;
                $getInsertFieldValue['species_f'] = $petSpecies;
                $getInsertFieldValue['notify_events_f'] = $notifyEvents;
                $lastInserted_user_id = $rm->insert_record($getInsertFieldValue, 'user_details_t');
                if (!empty($lastInserted_user_id)) {
                    //preparing list and inserting values in login table
                    $getInsertLoginDetails['password_f'] = $password;
                    $getInsertLoginDetails['user_name_f'] = $username;
                    $getInsertLoginDetails['user_id_fk'] = $lastInserted_user_id;
                    $lastInserted_login_id = $rm->insert_record($getInsertLoginDetails, 'login_t');
                    if (empty($lastInserted_login_id)) {
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    //preparing list and inserting values in friends table
                    $getInsertFriendDetails['friend_one'] = $lastInserted_user_id;
                    $getInsertFriendDetails['friend_two'] = $lastInserted_user_id;
                    $getInsertFriendDetails['created_date_f'] = $createdDate;
                    $getInsertFriendDetails['status'] = 2;
                    $lastInserted_friend_id = $rm->insert_record($getInsertFriendDetails, 'friends_t');
                    if (empty($lastInserted_friend_id)) {
                        $rm->delete('login_t', 'login_id', $lastInserted_login_id);
                        $rm->delete('user_details_t', 'user_id', $lastInserted_user_id);
                        $result = $rm->userRegisterFailJson();
                        return $result;
                    }
                    $IMAGEURLBASEURL = BASEURL . '/images/';
                    $userImageBaseURL = "images/{$username}";
                    if (!is_dir($userImageBaseURL)) {
                        //mkdir - tells that need to create a directory
                        mkdir($userImageBaseURL);
                        mkdir($userImageBaseURL . '/profile_pics/');
                        mkdir($userImageBaseURL . '/post_photos/');
                    }
                    $rand = rand(00, 99999);
                    if (isset($_POST['profile_pic']) and $_POST['profile_pic'] != "") {
                        $profile_pic = trim($_POST['profile_pic']);
                        //blob image data
                        $img = 'data:image/png;base64,' . $profile_pic . '';
                        $img = str_replace('data:image/png;base64,', '', $img);
                        $img = str_replace(' ', '+', $img);
                        $data = base64_decode($img);
                        $image = 'petbestie_user_' . $rand . '.png';
                        file_put_contents($userImageBaseURL . '/profile_pics/' . $image, $data);
                        //file_put_contents($userImageBaseURL.'/profile_pics/'.$image, $data);
                        $IMAGEURL = $IMAGEURLBASEURL . $username . '/profile_pics/' . $image;
                        $getUpdateProfilePic['profile_pic_f'] = $IMAGEURL;
                    } else {
                        $getUpdateProfilePic['profile_pic_f'] = "null";
                    }
                    $updateResult = $rm->update_record($getUpdateProfilePic, 'user_details_t', 'user_id', $lastInserted_user_id);
                    $result = $rm->userRegisterSuccessJson($lastInserted_user_id);
                    return $result;
                } else {
                    $result = $rm->userRegisterFailJson();
                    return $result;
                }
            }
            // end of else first
        } else {
            $result = $rm->ssl_error();
            return $result;
        }
    } else {
        $result = $rm->ssl_error();
        return $result;
    }
}
 public function sendPasswordEmail($user_id)
 {
     $rm = new Response_Methods();
     $rm->delete('recoveryemails_users', user_id_f, $user_id);
     $sqlFetch = "SELECT `user_name_f`,`email_f`,`pet_name_f` FROM `user_details_t` WHERE `user_id` = {$user_id} LIMIT 1";
     $result = mysql_query($sqlFetch, $GLOBALS['link']);
     $numRows = mysql_num_rows($result);
     if ($numRows > 0) {
         $row = mysql_fetch_array($result);
         $user_name = $row['user_name_f'];
         $user_email_id = $row['email_f'];
         $pet_name = $row['pet_name_f'];
         if (!$pet_name) {
             $pet_name = "user";
         }
         $expFormat = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 1, date("Y"));
         $expDate = date("Y-m-d H:i:s", $expFormat);
         $key = md5($user_name . '_' . $user_email_id . rand(0, 10000) . $expDate . PW_SALT);
         $sqlInsertKey = "INSERT INTO recoveryemails_users(user_id_f,recovery_key,expDate) VALUES ({$user_id},'{$key}','{$expDate}')";
         if (mysql_query($sqlInsertKey, $GLOBALS['link'])) {
             $passwordLink = "<a href=" . FORGET_PASSWORD_BASEURL . "/ForgotPassword.php?status=recover&email=" . $key . "&u=" . urlencode(base64_encode($user_id)) . ">" . FORGET_PASSWORD_BASEURL . "/ForgotPassword.php?status=recover&email=" . $key . "&u=" . urlencode(base64_encode($user_id)) . "</a>";
             $message = "Dear " . ucwords($pet_name) . ",\r\n\r\n";
             $message .= "Your username is: {$user_name}\r\n\r\n";
             $message .= "Please visit the following link to reset your password:\r\n";
             $message .= "-----------------------\r\n";
             $message .= "{$passwordLink}\r\n";
             $message .= "-----------------------\r\n";
             $message .= "Please be sure to copy the entire link into your browser. The link will expire after 1 days for security reasons.\r\n\r\n";
             $message .= "If you did not request this forgotten password email, no action is needed, your password will not be reset as long as the link above is not visited.\r\n\r\n";
             $message .= "Thanks,\r\n";
             $message .= "-- Petbesties Team";
             $headers .= "From: Petbesties <*****@*****.**> \n";
             $headers .= "To-Sender: {$user_name} <{$user_email_id}> \n";
             $headers .= "X-Mailer: PHP\n";
             // mailer
             $headers .= "Reply-To: shamsad@techilasolutions.com\n";
             // Reply address
             $headers .= "Return-Path: shamsad@techilasolutions.com\n";
             //Return Path for errors
             $headers .= "Content-Type: text/html; charset=iso-8859-1";
             //Enc-type
             $subject = "Petbestie-Reset Password";
             $message = str_replace("\r\n", "<br/ >", $message);
             //die($message);
             @mail($user_email_id, $subject, $message, $headers);
             /*Send the Success Message*/
             $errorCode = "1";
             $errorMsg = "Reset Password Link Successfully Sent to your email Id. ";
             $newData = "{\"data\":{\"Error_Code\":\"" . $errorCode . "\",\"Error_Msg\":\"" . $errorMsg . "\"}}";
             echo $newData;
             //return str_replace("\r\n","<br/ >",$message);
         } else {
             /*Send the Falure Message*/
             $errorCode = "0";
             $errorMsg = "Link Not Sent. Plz try again.. ";
             $newData = "{\"data\":{\"Error_Code\":\"" . $errorCode . "\",\"Error_Msg\":\"" . $errorMsg . "\"}}";
             echo $newData;
         }
     }
     //die($message);
 }