if (isset($_GET['msg']) && $_GET['msg'] != "") { //If they aren't logged on, don't let them make a new message if (!isset($user)) { die; } $msg = $_GET['msg']; //Grab the message $chat->userid = $user->id; //Get the user id $chat->post = htmlspecialchars($msg); //Make sure the message is safe on our webpage $chat->date = date("m-d-y H:i"); //Save the date $chat->name = $user->first_name; //Get the user's first name $chat->champion = $user->champion; //Get their champion $chat->status = $user->admin; //Check their user status $chat->saveChat($dbh); //Save the message } else { if (isset($_GET['fetch']) && $_GET['fetch'] != "") { $n = $_GET['fetch']; $chats = $chat->getNChats($dbh, $n); echo json_encode($chats); } } } else { die; }