header("HTTP/1.1 200 OK"); header("Content-Type: text/html"); $data = array('error' => 5); echo json_encode($data); $ok = true; } } else { if (strcmp($request['cmd'], 'register') == 0) { if ($userdata->userExists($request['username'])) { header("HTTP/1.1 200 OK"); header("Content-Type: text/html"); $data = array('error' => 10); echo json_encode($data); $ok = true; } else { if ($res = $userdata->addUser($request['username'], $request['firstname'], $request['lastname'], $request['password'], $request['email'], $request['organization'], $request['phone'], $request['data'])) { if ($res == "approval needed") { header("HTTP/1.1 200 OK"); header("Content-Type: text/html"); $data = array('pending' => 11); echo json_encode($data); $ok = true; } else { $_SESSION['username'] = $request["username"]; $_SESSION['id'] = $res; unset($_SESSION['project_id']); header("HTTP/1.1 200 OK"); header("Content-Type: text/html"); $data = array('username' => $request["username"], 'SID' => session_id()); echo json_encode($data); $ok = true;