:::

3-6-5 完成取消報名功能

您沒有觀看影片的權限

您沒有觀看影片的權限

請先登入,登入後,確認您的權限後,即可觀看影片。

  1. 樣板檔的刪除連結為:
    <a href="index.php?op=tad_signup_data_destroy&id=<{$id}>&action_id=<{$action_id}>" class="btn btn-danger"><i class="fa fa-times" aria-hidden="true"></i> 取消報名</a>

     

  2. 按下取消報名時, index.php 會收到 $op 值為 tad_signup_data_destroy,以及 $action_id$id 等變數,故 switch() 需新增相對應流程:
    //刪除報名資料
    case 'tad_signup_data_destroy':
        Tad_signup_data::destroy($id);
        // header("location: {$_SERVER['PHP_SELF']}?id=$action_id");
        redirect_header($_SERVER['PHP_SELF'] . "?id=$action_id", 3, "成功刪除報名資料!");
        exit;
    

     

  3. 修改 class/Tad_signup_data.php 中的 Tad_signup_data 類別下的 destroy() 方法 影片中資料庫大小寫不正確,一律改為小寫 prefix("tad_signup_data")
    //刪除某筆資料資料
    public static function destroy($id = '')
    {
        global $xoopsDB, $xoopsUser;
    
        if (empty($id)) {
            return;
        }
    
        $now_uid = $xoopsUser ? $xoopsUser->uid() : 0;
    
        $sql = "delete from `" . $xoopsDB->prefix("tad_signup_data") . "`
        where `id` = '{$id}' and `uid`='$now_uid'";
        if ($xoopsDB->queryF($sql)) {
            $TadDataCenter = new TadDataCenter('tad_signup');
            $TadDataCenter->set_col('id', $id);
            $TadDataCenter->delData();
        } else {
            Utility::web_error($sql, __FILE__, __LINE__);
        }
    }

     

link to https://github.com/tadlearn/tad_signup/commit/27a4fe4afb89d4675b0dbd20806b1ab13166883f \


:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D48%26tbdsn%3D1677

書籍目錄

展開 | 闔起

線上使用者

46人線上 (5人在瀏覽線上書籍)

會員: 0

訪客: 46

更多…