//telephonenumber update END
//telephonenumber delete BEGIN:
if (isset($_POST['tele_delete']) && isset($_POST['tele_id'])) {
    if (is_numeric($_POST['tele_id'])) {
        $query = sprintf("DELETE FROM phonenumbers WHERE id=%s", $dataB->sql_check($_POST['tele_id']));
        $dataB->sql_query($query);
        echo mysql_error();
    }
}
//telephonenumber delete END
//telephonnumber add BEGIN:
if (isset($_POST['add'])) {
    if (cellphone_number($_POST['telephonnr'])) {
        $typ = '2';
    } else {
        $typ = get_id_from_prefix($_POST['telephonnr']);
    }
    if (is_numeric($_POST['id'])) {
        $query = sprintf("INSERT INTO phonenumbers VALUES(NULL,%s,%s,%s,'{$typ}')", $dataB->sql_check($_POST['id']), $dataB->sql_check(strip_number($_POST['telephonnr'])), $dataB->sql_check($_POST['typ']));
        $result = $dataB->sql_query($query);
    }
}
//telephonnumber add END
if (isset($_POST['del']) or isset($_GET['del'])) {
    $template->assign_block_vars('check_if_delete_entry', array('L_check_if_you_will_delete' => $textdata['editadress_wirklich_loeschen']));
}
// Eintrag loeschen und neu mit gleicher ID reinschreiben.
if (isset($_POST['aendern'])) {
    if (is_numeric($_POST['id'])) {
        $query = sprintf("DELETE FROM addressbook WHERE id=%s", $dataB->sql_check($_POST['id']));
        $result = $dataB->sql_query($query);
            $typ = get_id_from_prefix($_POST['bhandy']);
        }
        $query = sprintf("INSERT INTO phonenumbers VALUES(NULL,'{$last_id}',%s,'2','{$typ}')", $dataB->sql_check(strip_number($_POST['bhandy'])));
        $result = $dataB->sql_query($query);
        if (!$result) {
            $template->assign_block_vars(array('show_error_msg_add_entry', 'L_MSG_ERROR_ADD_ENTRY' => $textdata['error_msg']));
            $template->pparse('overall_body');
            include "footer.inc.php";
            exit;
        }
    }
    if (isset($_POST['bfax']) && $_POST['bfax'] != "") {
        if (cellphone_number($_POST['bfax'])) {
            $typ = '2';
        } else {
            $typ = get_id_from_prefix($_POST['bfax']);
        }
        $query = sprintf("INSERT INTO phonenumbers VALUES(NULL,'{$last_id}',%s,'3','{$typ}')", $dataB->sql_check(strip_number($_POST['bfax'])));
        $result = $dataB->sql_query($query);
        if (!$result) {
            $template->assign_block_vars(array('show_error_msg_add_entry', 'L_MSG_ERROR_ADD_ENTRY' => $textdata['error_msg']));
            $template->pparse('overall_body');
            include "footer.inc.php";
            exit;
        }
    }
    $dataB->sql_close();
    if ($result) {
        $template->assign_block_vars('show_success_msg_forward_msg', array('FORWARD_ID' => "?id={$last_id}#find", 'L_MSG_SUCCESS_FORWARD' => $textdata['addadress_eintrag_aufgenommen_weiterleitung']));
    }
}