}
        echo "</ul>";
        break;
        
    case 'project_people':
        // a project has been selected.

        ?><div class="font-size-14 bold">Select the people you want to invite from the lists below:</div><?

        // first, find all the company ids we can.
        // - start with the one in the project info
        $project_id = (int)@$_REQUEST['project'];
        $company_ids = array((int)@$_REQUEST['project_company'] => @$_REQUEST['project_company_name']);

        // - then scrape the contact list and add those in too
        foreach ($bc->companies() as $company) {
            $cid = (int)$company['id'];
            if (!@$company_ids[$cid]) $company_ids[$cid] = $company['name'];
        }

        $form_id = 1000; // start at 1000 so we don't overlap with the entered names/emails

        // now fetch all people from each company that are on the given project
        foreach ($company_ids as $company_id => $company_name) {
            $existing_people = array();
            $new_people = array();
            echo '<div class="font-size-14" style="background-color: #f0f0f0; width: 100%">Company: '.htmlspecialchars($company_name).'</div>';
            foreach ($bc->people($company_id, $project_id) as $person) {
                $email = $person->{'email-address'};
                try {
                    $u = new User();
?>
"></td></tr>
<tr><td></td><td><input type="submit" value="Get your basecamp info"></td></tr>
</table>
</form><?

if (!$bc_login || !$bc_password) {
    echo "<p>please enter your basecamp login details above.</p>";
    exit;
}

$bc = new BaseCampClient($bc_url, $bc_login, $bc_password);

echo "<p>scraping contacts page to get companies</p>"; flush();

$companies = $bc->companies();

foreach ($companies as $company) {
    
    echo "<h1>company: ".htmlspecialchars($company['name'])."</h1>";
    foreach ($company['people'] as $person) {
	echo '<li><a href="mailto:'.$person['email'].'">'.$person['name'].'</a></li>';
    }
}

echo "<p>getting project list</p>"; flush();

$projects = $bc->list_projects();

foreach ($projects as $project) {
    echo "<h1>project</h1>";