Пример #1
0
function add_points_if_necessary($id)
{
    $connection = new PDO("mysql:host=" . DB_HOST . ";dbname=" . DB_NAME, DB_USER, DB_PWD);
    if (have_points_already_been_added($id)) {
        return false;
    }
    $statement = $connection->prepare("update users set points=points+1 where id=?");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
    $points = fetch_user_points($id);
    $statement = $connection->prepare("insert into point_log (user_id, total) values (?, {$points})");
    $statement->bindValue(1, $id, PDO::PARAM_INT);
    $statement->execute();
}
Пример #2
0
    ?>
        <body id="AchievementsList">
            <div id="error"></div>
                <div style='float:right;font-size:12px;'>
                    <?php 
    if (!isset($_SESSION['user'])) {
        ?>
                    Not logged in.
                    <a href='signup/' class='text-button' style='margin-left:2px;font-size:12px;float:right;'>[ Sign Up ]</a> 
                    <a href='login/' class='text-button' style='margin-left:4px;font-size:12px;float:right;'>[ Login ]</a>
                    
                    <?php 
    } elseif (fetch_current_user_id() != false) {
        ?>
                        Logged in as <?php 
        echo fetch_username(fetch_current_user_id()) . ". (" . fetch_user_points(fetch_current_user_id()) . ")";
        ?>
 
                        <span id='logout' class='hand text-button'> [ Logout ] </span>
                    <?php 
    }
    ?>
                </div>
            <?php 
    if (isset($_SESSION['user'])) {
        ?>
            <div>
                <input id="new_achievement_text_input" type='text' maxlength="255" />          
                <input id="new_achievement_button" type="button" value="Quick Create" />
            </div>
            <?php