view.php 3.48 KB
Newer Older
Ranindya Paramitha's avatar
Ranindya Paramitha committed
1
<?php 
Ranindya Paramitha's avatar
Ranindya Paramitha committed
2
    require_once ("../autoload.php");
3
    include("controller.php");
4
    // echo $_COOKIE["login"];
Ranindya Paramitha's avatar
Ranindya Paramitha committed
5
    if (!isset($_COOKIE["login"])){
6
        // echo "TAK";
Ranindya Paramitha's avatar
Ranindya Paramitha committed
7 8 9 10
        $user_token = NULL;
    } else{
        $user_token = $_COOKIE["login"];
    }
Ranindya Paramitha's avatar
Ranindya Paramitha committed
11
    //user ada
Ranindya Paramitha's avatar
Ranindya Paramitha committed
12 13 14 15 16
    if ($user_token != NULL){
        $user_id = getUserIDbyToken($user_token);
    } else{
        $user_id = 0;
    }
Ranindya Paramitha's avatar
Ranindya Paramitha committed
17 18
    echo "<html>";

19
    echo Header::generateHeadWithJS("edit_profile", "edit_profile", "edit_profile");
Ranindya Paramitha's avatar
Ranindya Paramitha committed
20
    echo Header::headerLogin(getUsername($user_token));
Ranindya Paramitha's avatar
Ranindya Paramitha committed
21
    echo Header::headerMenu(Header::PROFILE);
22
    
Ranindya Paramitha's avatar
Ranindya Paramitha committed
23 24 25 26 27 28
    $user_profile = getUserProfile($user_id);
    $user_pp = $user_profile['profile_picture'];
    $user_name = $user_profile['name'];
    $user_address = $user_profile['address'];
    $user_phone = $user_profile['phone'];

29
    echo "<body onload=\"def = getDefault();\">";
30
    echo '<form action="../edit_profile/edit_profile.php" enctype="multipart/form-data" onsubmit="return (validateForm())"method = "POST">'   ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
31 32 33 34 35 36 37

    echo "<div class=\"cols\">" ;

    echo "<h1>Edit Profile</h1>"    ;

    echo "<div class = \"rows1\">"  ;
    echo "<div class=\"left\">" ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
38
    if (!fileProcessing::isExistProfileImage($user_pp)){
39 40
        $user_pp = "default.jpg";
    }
41
    echo "<img class=\"pp\" src=\"../uploads/$user_pp\" alt=\"Profile Picture\">"  ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
42 43 44 45
    echo "</div>";

    echo "<div class=\"right\">"    ;
    echo "<p>Update profile picture</p>"    ;
46 47 48 49 50 51 52 53 54 55 56

    echo '
        <div class="flex-container">
            <input id="profpict_dummy" class="profpict_dummy"type="text" name="profile_picture2" readonly>
            <div class="upload-btn-wrapper">
                <button class="btn">Browse ...</button>
                <input id="profpict" type="file" name="profile_picture" accept="image/png, image/jpg, image/jpeg" onchange="showname()" >
            </div>   
        </div>
    ';

Ranindya Paramitha's avatar
Ranindya Paramitha committed
57 58 59 60 61 62
    echo "</div>"   ;
    echo "</div>"   ;

    echo "<div class=\"rows2\">"    ;
    echo "<p class=\"left2\">Name</p>"  ;
    echo "<div class=\"right2\">"   ;
63
    echo '<p id="warning-1" class="red-theme alert-box text-size-20 add-nunito-font c-round">Input can\'t be empty</p>';
64
    echo "<input type=\"text\" id = \"name\" name=\"name\" value=\"$user_name\">"   ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
65 66 67 68 69 70
    echo "</div>"   ;
    echo "</div>"   ;

    echo "<div class=\"rows\">" ;
    echo "<p class=\"left2\">Address</p>"   ;
    echo "<div class=\"right2\">"   ;
71
    echo '<p id="warning-2" class="red-theme alert-box text-size-20 add-nunito-font c-round">Input can\'t be empty</p>';
72
    echo "<textarea name=\"address\" id = \"address\" rows=\"5\" cols=\"1\">$user_address</textarea>"   ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
73 74 75 76 77 78
    echo "</div>"   ;
    echo "</div>"   ;

    echo "<div class=\"rows2\">"    ;
    echo "<p class=\"left2\">Phone number</p>"  ;
    echo "<div class=\"right2\">"   ;
79
    echo '<p id="warning-3" class="red-theme alert-box text-size-20 add-nunito-font c-round">Input can\'t be empty</p>';
80
    echo "<input type=\"text\" id = \"phone\" name=\"phone\" value=\"$user_phone\">" ;
Ranindya Paramitha's avatar
Ranindya Paramitha committed
81 82 83 84 85 86
    echo "</div>"   ;
    echo "</div>"   ;
    echo "</div>"   ;

    echo "<div class=\"row_button\">";
    echo "<div class=\"left_button\">";
87
    echo "<button id=\"back\" type=\"button\" name=\"back\" value=\"BACK\" onclick=\"location.href = '../profile'\">Back</button>";
Ranindya Paramitha's avatar
Ranindya Paramitha committed
88 89
    echo "</div>";
    echo "<div class=\"right_button\">";
90
    echo "<input id=\"submit\" type=\"submit\" name = \"submit\"value =\"SAVE\">";
Ranindya Paramitha's avatar
Ranindya Paramitha committed
91 92 93 94 95 96 97 98 99
    echo "</div>";
    echo "</div>";

    echo "</form>"  ;
    echo "</body>";
    echo "</html>";
?>