<?php
/**
 * Created by PhpStorm.
 * User: jaskokoyn
 * Date: 2/20/2015
 * Time: 1:09 PM
 */

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

if(!isset($_SESSION['loggedin']) || $user['mem_level'] != 2){
    die("AYYYYYY");
}

if( !isReady($_POST, array( "uid", "username", "email", "level" ) ) ){
    die( "EMPTY" );
}

$uid        =   intval($_POST['uid']);
$username   =   secure($_POST['username']);
$email      =   secure($_POST['email']);
$location   =   secure($_POST['location']);
$age        =   secure($_POST['age']);
$gender     =   secure($_POST['gender']);
$about      =   secure($_POST['about']);
$level      =   secure($_POST['level']);

$updateUserQuery    =   $db->prepare("UPDATE users SET  username = :u,
                                                        email = :e,
                                                        location = :l,
                                                         age = :a,
                                                         gender = :g,
                                                         about = :about,
                                                         mem_level = :ml
                                                         WHERE id = :id");
$updateUserQuery->execute(array(
    ":u"        =>  $username,
    ":e"        =>  $email,
    ":l"        =>  $location,
    ":a"        =>  $age,
    ":g"        =>  $gender,
    ":about"    =>  $about,
    ":ml"       =>  $level,
    ":id"       =>  $uid
));

die("SUCCESS");