<?php
/**
 * Created by PhpStorm.
 * User: jaskokoyn
 * Date: 2/19/2015
 * Time: 6:39 PM
 */

require('../../inc/db.php');
include('../../inc/functions.php');

$params                 =   getParams();
$output                 =   array('status' => 1);

if(!isset($_SESSION['loggedin'])){
    dj($output);
}

$loc                    =   secure($params['location']);
$age                    =   intval($params['age']);
$gender                 =   intval($params['gender']);
$about                  =   substr(secure($params['about']), 0, 500);
$status                 =   substr(secure($params['profile_status']), 0, 80);

$updateUserQuery        =   $db->prepare("UPDATE users
                                          SET location = :l,
                                              age = :a,
                                              gender = :g,
                                              about = :ab,
                                              profile_status = :ps
                                          WHERE id = :id");
$updateUserQuery->execute(array(
    ":l"                =>  $loc,
    ":a"                =>  $age,
    ":g"                =>  $gender,
    ":ab"               =>  $about,
    ":ps"               =>  $status,
    ":id"               =>  $_SESSION['uid']
));

$output['status']       =   2;
dj($output);