} else { if ($operation == "login") { /*Login using the credentials passed in returns userId if successful, -0- otherwise*/ $rc = goUserSettings::login($userName, $password); if ($rc == 0) { header("Location:" . $_SERVER['PHP_SELF'] . "?errormessage=" . urlencode("Invalid user name or password")); exit; } $userSettings = new goUserSettings(); $rc = $userSettings->getUserSettings($userName, 'Yes'); /* TODO - add code to determine if the retrieval failed due to error or because the userid or username not defined. For now assume error */ if (!rc) { // Server error mydie("Error connecting to Database"); } $userID = $userSettings->getuserID(); setcookie('userid', $userID); setcookie('username', $userSettings->getUserName()); header("Location: " . Config::getRootDomain()); } else { if ($operation == "register") { // make sure we have the minimum necessary populated fields if (empty($newUserName) || empty($newPassword)) { } /* first take care of inserting new user into go_user table */ $rc = insertNewUser($params); if (!$rc) { header("Location:" . $_SERVER['PHP_SELF'] . "?errormessage=" . urlencode("User name {$userName} not available")); exit; } // if