diff --git a/app/models/Course.php b/app/models/Course.php index c60ed5debce4d6e70c428325ededaf347e1e94ac..d44f0bfcee9cfc13fc2d2f45a0305cb61a1e2845 100644 --- a/app/models/Course.php +++ b/app/models/Course.php @@ -54,7 +54,6 @@ require_once(__DIR__."/Model.php"); } public function searchCourses($data){ - // print_r($data); $query = "SELECT * FROM courses "; $search = false; if(isset($data["title"])){ diff --git a/app/views/profile/index.php b/app/views/profile/index.php index 6ac9de6e381ff9c748e539d5671bb31b1c9db748..d6aff009e70d95d0f5cd13afd835ac688eaca07f 100644 --- a/app/views/profile/index.php +++ b/app/views/profile/index.php @@ -10,6 +10,17 @@ </head> <body> + <?php + if (session_status() === PHP_SESSION_NONE) { + session_start(); + } + // JIKA USER SUDAH LOGIN, PROFILE DITUNJUKKAN + if (isset($_SESSION["user_id"])) { + // Fetch the user by ID + include __DIR__ . '/../navbar/navbar.php'; + $thisUser = $user->getUserById($_SESSION["user_id"]); + } + ?> <section class='popup-section'> <div class='popup-overlay'></div> <div class='popup-box'> @@ -28,101 +39,84 @@ </div> </div> </section> - <?php - if (session_status() === PHP_SESSION_NONE) { - session_start(); - } - // JIKA USER SUDAH LOGIN, PROFILE DITUNJUKKAN - if (isset($_SESSION["user_id"])) { - // Fetch the user by ID - include __DIR__ . '/../navbar/navbar.php'; - $thisUser = $user->getUserById($_SESSION["user_id"]); - echo " - <section class='home-section'> - <div class='profile-forms'> - <form class='profile-create' id='form-register' action='javascript:' onsubmit='return handleUpdate({$thisUser['user_id']})'> - <h1 class='profile-title profile-toggle-fixed'>Profile</h1> - <h1 class='profile-title profile-toggle-change'>Change Profile</h1> + <section class='home-section'> + <div class='profile-forms'> + <form class='profile-create' id='form-register' action='javascript:' onsubmit="return handleUpdate(<?= $thisUser['user_id']; ?>)"> + <h1 class='profile-title profile-toggle-fixed'>Profile</h1> + <h1 class='profile-title profile-toggle-change'>Change Profile</h1> - <input type='hidden' id='oldPicture' value='{$thisUser['image_path']}'> - <div style='display: block;'> - <img src='{$thisUser['image_path']}' id='profilePicture' alt='profile picture'> - </div> + <input type='hidden' id='oldPicture' value=<?= $thisUser['image_path'] ?>> + <div style='display: block;'> + <img src=<?= $thisUser['image_path'] ?> id='profilePicture' alt='profile picture'> + </div> - <div class='profile-toggle-change'> - <div class='picture-button'> - <label for='default-picture-button' class='delete-picture'>Delete</label> - <label for='files' class='change-picture'>Change</label> - <button type='button' id='default-picture-button' onclick='deleteProfilePictureChange();'></button> - <input id='files' type='file' accept='.jpg, .jpeg, .png' onchange='previewProfilePicture(this)'> - </div> - </div> + <div class='profile-toggle-change'> + <div class='picture-button'> + <label for='default-picture-button' class='delete-picture'>Delete</label> + <label for='files' class='change-picture'>Change</label> + <button type='button' id='default-picture-button' onclick='deleteProfilePictureChange();'></button> + <input id='files' type='file' accept='.jpg, .jpeg, .png' onchange='previewProfilePicture(this)'> + </div> + </div> - <div class='profile-box' id='fullname-box'> - <p>Fullname :</p> - <input type='text' - placeholder='New Full Name' - name='fullname' - id='fullname-input' - class='profile-input' - value='{$thisUser['fullname']}' - onkeyup = 'check_fullname()' - required - disabled - /> - </div> - <p id='fullname-alert'></p> + <div class='profile-box' id='fullname-box'> + <p>Fullname :</p> + <input type='text' + placeholder='New Full Name' + name='fullname' + id='fullname-input' + class='profile-input' + value=<?= $thisUser['fullname'] ?> + onkeyup = 'check_fullname()' + required + disabled + /> + </div> + <p id='fullname-alert'></p> - <input type='hidden' id='oldUsername' value='{$thisUser['username']}'> - <div class='profile-box' id='username-box'> - <p>Username :</p> - <input type='text' - placeholder='New Username' - id='username-input' - name='username' - class='profile-input' - value='{$thisUser['username']}' - onkeyup = 'check_username()' - required - disabled - /> - </div> - <p id='username-alert'></p> + <input type='hidden' id='oldUsername' value=<?= $thisUser['username'] ?>> + <div class='profile-box' id='username-box'> + <p>Username :</p> + <input type='text' + placeholder='New Username' + id='username-input' + name='username' + class='profile-input' + value=<?= $thisUser['username'] ?> + onkeyup = 'check_username()' + required + disabled + /> + </div> + <p id='username-alert'></p> - <div class='profile-toggle-change'> - <div class='profile-box' id='password-box'> - <p>Password :</p> - <input - type='password' - placeholder='New Password (optional)' - id='password-input' - name='password' - class='profile-input' - onkeyup='check_password()' - disabled - /> - </div> - </div> - <p id='password-alert'></p> - <div class='profile-toggle-change'> - <div class='change-buttons' style='display:flex;'> - <button type='reset' class='cancel-change-button' id='cancel-change-button' onclick='toggle(); cancelProfilePictureChange();'>Cancel</button> - <button type='button' class='save-button' id='save-profile-button' onclick='confirmChanges()' disabled>Save</button> - </div> - </div> - <div class='profile-toggle-fixed'> - <button type='button' onclick='toggle()' class='edit-button' id='profile-button'>Edit</button> - </div> - </form> - </div> - </section> - "; - } else { - // JIKA USER BELUM LOGIN, PAGE PROFILE TIDAK BISA - - exit; - } - ?> + <div class='profile-toggle-change'> + <div class='profile-box' id='password-box'> + <p>Password :</p> + <input + type='password' + placeholder='New Password (optional)' + id='password-input' + name='password' + class='profile-input' + onkeyup='check_password()' + disabled + /> + </div> + </div> + <p id='password-alert'></p> + <div class='profile-toggle-change'> + <div class='change-buttons' style='display:flex;'> + <button type='reset' class='cancel-change-button' id='cancel-change-button' onclick='toggle(); cancelProfilePictureChange();'>Cancel</button> + <button type='button' class='save-button' id='save-profile-button' onclick='confirmChanges()' disabled>Save</button> + </div> + </div> + <div class='profile-toggle-fixed'> + <button type='button' onclick='toggle()' class='edit-button' id='profile-button'>Edit</button> + </div> + </form> + </div> + </section> </body> </html> \ No newline at end of file diff --git a/public/js/search.js b/public/js/search.js index 52af64ee2a57fd66faaa14e3243a7a687a583770..026f278bce46fed4857af2a23c9fdb55c6697a5d 100644 --- a/public/js/search.js +++ b/public/js/search.js @@ -43,7 +43,6 @@ const searchCourse = (page_number = 1) => { const xhr = new XMLHttpRequest(); xhr.open("GET", final_url, true); xhr.onload = function () { - console.log(this); if (this.status === 200) { let data = JSON.parse(this.responseText); let courses = data["courses"];