$strERRORUserMessage="Database user update Error. Admin has been informed ".$strError_send; $strERRORMessageAdmin="$strError_send \n SQL statement failed - $query ";
         	mysqli_query($DB_LINK, $query) or funct_die_with_grace(mysqli_error(), $strERRORUserMessage, $strERRORMessageAdmin, $strERRORPage) ;
         	$strErrorMessage2 = $strErrorMessage2. " user was credited ";
         }
         */
         $strSubject = "FAILED External SEND - {$strNetwork} Send ({$intBTCamt} {$strCrypto}) \$" . number_format($intUSDamt, 2) . " USD by {$intUserID} " . $strFirstName . " " . $strLastName;
         $strBody = " External Block Chain send Failed - {$strErrorMessage2} \n\n" . "strSendMsg: {$strSendMsg} \n strSendErr: {$strSendErr} \n strSendHash: {$strSendHash}  \n " . "Data sent to function funct_Billing_SendBTC( {$strWalletHash}, {$intBTCamt}, {$strNote}, {$intMiningFee}, {$strWalletFrom} ) \n " . "amt: {$intBTCamt} {$strCrypto} \n total outflow: {$intCryptoTotal_Outflow} \\ mining fee: {$intMiningFee} \\ balance prev: {$balance_prev_sender} \n balance curr: {$balance_curr_sender} \n new balance: {$intBalanceCrypto} {$strCrypto} \n usd: \$ {$intUSDamt} \n " . "email: {$strEmail} \n phone: {$strPhone} \n ip address: {$strIPAddress} \n Label: {$strLabel} \n" . "Member Details: " . WEBSITEFULLURL . "/cp/member_details.php?id={$intUserID}\n";
         funct_Mail_simple(EMAIL_WALLETSEND, $strSubject, $strBody, '', $strEmail);
         //################################################################################################
     }
 }
 //end if networksend = blockchain aka external
 //for send via email
 if ($strNetwork == "email" and !$strError_send) {
     //generate a random unique 24 character code they will use to claim the bitcoins
     $strCode = createRandomKey_Num(24);
     $strEmailCoinsLink = WEBSITEFULLURLHTTPS . CODE_DO . "?do=claimcoins&email=" . $strSendToEmailAddress . "&code=" . $strCode;
     //add a record to the escrow table via email $intBTCamt $strLabel
     $status_id = "0";
     //waiting..
     $status_msg = "waiting to be claimed";
     $query = "INSERT INTO " . TBL_ESCROW . " ( user_id,\t\tuser_email,\tcrypto_amount, crypto_rate, address_email, \t\t\t\tverify_code, \ttransaction_id_send,\tlabel,\t\t\tdate_created,\tdate_filled,\tstatus,\t\t\tstatus_msg,\t\tipaddress \t\t) VALUES " . " ( '{$intUserID}',\t'{$strEmail}','{$intBTCamt}',\t'{$intRate}',\t'{$strSendToEmailAddress}',\t'{$strCode}',\t\t'{$intNewOrderID}',\t\t'{$strLabel}',\tNOW(),\t\t\tNOW(),\t\t\t'{$status_id}',\t'{$status_msg}',\t'{$strIPAddress}' ) ";
     $strERRORUserMessage = "Database add escrow record Error. Admin has been informed " . $strError_send;
     $strERRORMessageAdmin = "{$strError_send} \n SQL statement failed - {$query} ";
     mysqli_query($DB_LINK, $query) or funct_die_with_grace(mysqli_error(), $strERRORUserMessage, $strERRORMessageAdmin, $strERRORPage);
     $intNewEscrowID = mysqli_insert_id($DB_LINK);
     //email the receiver an link to the bitcoins
     $strSubject = "You Got Bitcoin " . $strFirstName . " " . $strLastName;
     $strBody = "amt: {$intBTCamt} {$strCrypto} \n was just sent to you by {$strFirstName} {$strLastName} - {$strEmail}  \n" . "To Claim your coins and your free Wallet Please click this link \n" . "{$strEmailCoinsLink} \n " . WEBSITENAME . " thank you ";
     funct_Mail_simple($strSendToEmailAddress, $strSubject, $strBody, '', $strEmail);
     $strSendHash = "email";
 //Execute it
 $stmt->bind_result($intUserID);
 //bind results
 //$stmt -> fetch(); //fetch the value
 mysqli_stmt_store_result($stmt);
 $intTotalRowsFound = mysqli_stmt_num_rows($stmt);
 //echo "totalrows: $intTotalRowsFound <br>";
 if ($intTotalRowsFound < 1) {
     $errorMSG = "Sorry, the  email: " . $strEmailForgotForm . " is not in our records";
     //No Such Email in Database
 } else {
     //Email found so ...
     while ($stmt->fetch()) {
         //echo " $intUserID, $strFirstName, $strLastName, $strEmail <br>";
         //generate temp password
         $strPasswordTemp = createRandomKey_Num(12);
         //hash it
         $strPassword_hash = password_hash($strPasswordTemp, PASSWORD_DEFAULT);
         //PASSWORD_BCRYPT
         //update database
         //$query = "UPDATE ".TBL_USERS." SET password='******' WHERE id = $intUserID " ;
         //echo "SQL STMNT = " . $query .  "<br>";
         //$rs = mysqli_query($DB_LINK, $query) or die(mysqli_error());
         if ($DB_MYSQLI->connect_errno) {
             echo "Failed to connect to MySQL: (" . $DB_MYSQLI->connect_errno . ") " . $DB_MYSQLI->connect_error;
         }
         if (!($stmt = $DB_MYSQLI->prepare("UPDATE " . TBL_USERS . " SET password = ? WHERE id = ? "))) {
             echo "Prepare failed: (" . $DB_MYSQLI->errno . ") " . $DB_MYSQLI->error;
         }
         if (!$stmt->bind_param('sd', $strPassword_hash, $intUserID)) {
             echo "Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error;
function funct_SendEmailCode($intUserID)
{
    global $DB_LINK;
    //Allows Function to Access variable defined in constants.php ( database link )
    //generate unique code
    $intCode = createRandomKey_Num(12);
    //update member record
    $query = "UPDATE " . TBL_USERS . " SET emailcode='{$intCode}' WHERE id = {$intUserID} ";
    //echo "SQL STMNT = " . $query . "<br>";
    $rs = mysqli_query($DB_LINK, $query) or die(mysqli_error());
    //get email
    $query = "SELECT * FROM " . TBL_USERS . " WHERE id = {$intUserID} ";
    //echo "SQL STMNT = " . $query . "<br>";
    $rs = mysqli_query($DB_LINK, $query) or die(mysqli_error());
    $row = mysqli_fetch_array($rs);
    $strEmail = $row["email"];
    $strEmailLink = WEBSITEFULLURLHTTPS . CODE_DO . "?do=confirmemailcode&emailcode=" . $intCode;
    //send email
    $strSubject = WEBSITENAME . " Verification Code " . $intCode;
    $strBody = "Your " . WEBSITENAME . " Verification Code is \n " . $intCode . " \n " . $strEmailLink;
    funct_Mail_simple($strEmail, $strSubject, $strBody);
    //$name=EMAIL_FROM_NAME ; $strFromName=WEBSITENAME ; $strFromEmail=EMAIL_FROM_ADDR ;
    //$strError = functSendEmail($strEmail, $strSubject, $strBody, $name, $strFromName, $strFromEmail);
    return $strError;
}