Why does code work on one server and not another

I created a database driven website for a school’s reading program as a subdomain on my personal website. When we tried to move the files to a domain purchased by the school, the PHP no longer works properly.

On the new domain, the user click “Login” on the home page, a login screen appears and with correct information user is taken to a page where they can select a calendar to populate. Once the calendar is selected, the login screen appears again. This is not supposed to happen. It does not happen on my server.

Here is the code in the access.inc.php which is called on every internal page.

<?php

session_start();

function loggedIn()
{
  return isset($_SESSION['authorized']);
}


// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'user', 'password');
if (!$dbcnx) {
  exit('<p>Unable to connect to the ' .
      'database server at this time.</p>');
}

// Select the database
if (!@mysql_select_db('database')) {
  exit('<p>Unable to locate the ' .
      'database at this time.</p>');
}
?>

<?php
if (isset($_POST['submit'])) {

//This makes sure no fields are left blank
 if (!$_POST['idnumber'] | !$_POST['lastname']) {
         exit('<p>You must enter the students IDNumber and Last Name to continue. Click the BACK button and enter all required information.</p>');
     }

//This selects the IDNumber from the database
$select = 'SELECT *';
$from = ' FROM Students';
$where = ' WHERE 1=1';

$idnumber = $_POST['idnumber'];
$lastname = strtoupper($_POST['lastname']);
if ($idnumber != '') {
    $where .= " AND IDNumber = '" . $idnumber . "'";
    }

$result = mysql_query($select . $from . $where);
    if (!$result){
    echo '</table>';
    exit('<p>Error retrieving the ID Number from the database!<br />' .
        'Error: ' . mysql_error() . '</p>');
    }

while ($row = mysql_fetch_array($result)) {
    $dbidnumber = $row['IDNumber'];
        $dblastname = $row['LastName'];
        $dbfirstname = $row['FirstName'];
        $student = $dbfirstname . " " . $dblastname;
    }

//gives error if the Last Name entered does not match the last name in the database
     if ($lastname != $dblastname) {
         exit('You entered the incorrect Last Name for the ID Number. Click the BACK button and enter the correct information.');
}

else

// Process login attempt
if (isset($_POST['idnumber'])) {
  if ($_POST['idnumber'] == $dbidnumber and
      strtoupper($_POST['lastname']) == $dblastname) {
      $_SESSION['authorized'] = true;
  }
}
}

// Process logout
if (isset($_REQUEST['logout'])) {
  unset($_SESSION['authorized']);
}

?>

Common causes of incompatibility are usually due to PHP/Server settings.

The most common culprit is register_globals.

Clearly the behaviour points to a loss of session, or incorrect session settings.

By the way, the two servers that I am using are on aplus.net (works) and fatcow.com (does not work).

How do change those settings?