title: Authentication Logon page not working using PHP and Oracle on Apache / Windows 2008
body: <p>[UPDATE: Solved: Thanks everyone. See code here: http://pastebin.com/1fJmXeG2] I greatly appreciate any help I can get on this problem. We have a logon page on our site running on an old Linux server using Apache 1 and PHP 4. We want to move it to a new Windows 2008 server (64-bit)... so I installed Apache 2.25 and PHP 5.4 on the new server. I also enabled OCI8 connecting to an Oracle 11g database. I moved the files for the logon page over to the new server and they don't work. What happens is the page does not run the script and it just forwards to the index.php instead of redirecting to index php with the appropriate response. Of course there was some deprecated language which I updated in the PHP script, but it still doesn't work. I am a complete newbie so I am not sure if it is a problem with the script or a problem with the PHP settings. I know I can connect to the database, since I made a test page doing so. Please help me if you can... I am really desperate. The following is the code for my authorization page:</p>
  
  <pre><code>&lt;?php session_start();
  // Begin or continue session by registering variables
  $_SESSION['USER_ID'] = 'USER_ID';
  $_SESSION['PASSWORD'] = 'PASSWORD';
  $_SESSION['FIRST'] = 'FIRST';
  $_SESSION['LAST'] = 'LAST';
  $_SESSION['ACCESS_KEY'] = 'ACCESS_KEY';
  $_SESSION['conn'] = 'conn';
  $_SESSION['BEENHERE'] = 'BEENHERE';
  $_SESSION['CUSTOMER_NAME'] = 'CUSTOMER_NAME';
  $_SESSION['WAREHOUSING'] = 'WAREHOUSING';
  $_SESSION['TRANSPORTATION'] = 'TRANSPORTATION';
  $_SESSION['MYACCOUNT'] = 'MYACCOUNT';
  
  // Set Environment Variables
  $SYS_DBUSER = "*****";
  $SYS_DBPASSWORD = "*****";
  $SYS_DB = "*****";
  
  // Begin Authorization Routine
  if ( (!isset($USER_ID)) &amp;&amp; (!isset($PASSWORD)) )
      {
      echo '&lt;html&gt;';
      echo '&lt;head&gt;';
      echo '&lt;title&gt; Customer Access - Login&lt;/title&gt;';
      echo '&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;';
      echo '&lt;/head&gt;';
      echo '&lt;body bgcolor="#FFFFFF" text="#000000"&gt;';
      echo '&lt;div align="center"&gt;';
      echo '&lt;p&gt;&lt;img src="../images/logocir3.gif" width="120" height="123"&gt; &lt;/p&gt;';
      echo '&lt;p&gt;&lt;b&gt;&lt;font size="5" color="#0000FF" face="Arial, Helvetica, sans-serif"&gt;The ';
      echo 'The Company&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;';
      echo '&lt;p&gt;&lt;font size="4" color="#0000FF" face="Arial, Helvetica, sans-serif"&gt;&lt;b&gt;&lt;i&gt;Customer Access&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;';
      echo '&lt;form name="form1" method="post" action="index.php"&gt;';
      echo '&lt;p&gt; &lt;font size="3" face="Arial, Helvetica, sans-serif"&gt;Username:&lt;/font&gt; ';
      echo '&lt;input type="text" name="USER_ID" maxlength="15"&gt;';
      echo '&lt;/p&gt;';
      echo '&lt;p&gt;&lt;font size="3" face="Arial, Helvetica, sans-serif"&gt;Password: &lt;/font&gt; ';
      echo '&lt;input type="PASSWORD" name="PASSWORD" maxlength="15"&gt;';
      echo '&lt;/p&gt;';
      echo '&lt;p&gt;&lt;input type="submit" name="Submit" value="Login"&gt;&lt;/p&gt;';
      echo '&lt;/form&gt;';
      echo '&lt;p&gt;&amp;nbsp;&lt;/p&gt;';
      echo '&lt;/div&gt;';
      echo '&lt;/body&gt;';
      echo '&lt;/html&gt;';
      exit;
      }
  elseif ( ($BEENHERE == 1) &amp;&amp; (isset($FIRST)) &amp;&amp; (isset($PASSWORD)) &amp;&amp; (isset($ACCESS_KEY)) &amp;&amp; (isset($USER_ID)) &amp;&amp; (isset($LAST)) &amp;&amp; (isset($conn)) &amp;&amp; (isset($CUSTOMER_NAME)) )
      {
      return (TRUE);
      }
  else
      {
      // Connect to database
      unset($conn);
      $conn = oci_connect($SYS_DBUSER,$SYS_DBPASSWORD,$SYS_DB);
  
      // Generate sql statement
      $loginsql = oci_parse($conn,"SELECT FIRST_NAME,LAST_NAME,CUSTOMER_NAME,ACCESS_KEY,TRANSPORTATION,WAREHOUSING,MYACCOUNT FROM WEB_USERS WHERE USER_ID = SUBSTR(UPPER('$USER_ID'),1,15) AND PASSWORD = SUBSTR(UPPER('$PASSWORD'),1,30) AND ENABLED = 'Y'");
  
      // Execute statement
      oci_execute($loginsql,OCI_NO_AUTO_COMMIT);
  
      // Retrieve number of rows for authentication
      $nrows = oci_fetch_all($loginsql,$results);
  
      // Database Authenticate
      if ( $nrows != 1 )
          {
          // Display if login fails
          unset($USER_ID);
          unset($PASSWORD);
          unset($FIRST);
          unset($LAST);
          unset($ACCESS_KEY);
          unset($conn);
          unset($BEENHERE);
          unset($CUSTOMER_NAME);
          unset($WAREHOUSING);
          unset($TRANSPORTATION);
          unset($MYACCOUNT);
          echo "&lt;H1&gt;Login Failure - Please Check Your Password AND/OR Username&lt;/H1&gt;&lt;BR&gt;";
          echo "&lt;A HREF=\"$PHP_SELF\"&gt;&lt;H3&gt;Try Again&lt;/H3&gt;&lt;/A&gt;";
  
          // Close used resources
          oci_free_statement($loginsql);
          oci_close($conn);
          exit;
          }
      else
          {
          // Assign login information to global variables
          unset($FIRST);
          unset($LAST);
          unset($ACCESS_KEY);
          unset($BEENHERE);
          unset($CUSTOMER_NAME);
          unset($WAREHOUSING);
          unset($TRANSPORTATION);
          unset($MYACCOUNT);
          $FIRST = $results['FIRST_NAME'][0];
          $LAST = $results['LAST_NAME'][0];
          $CUSTOMER_NAME = $results['CUSTOMER_NAME'][0];
          $ACCESS_KEY = $results['ACCESS_KEY'][0];
          $TRANSPORTATION = $results['TRANSPORTATION'][0];
          $WAREHOUSING = $results['WAREHOUSING'][0];
          $MYACCOUNT = $results['MYACCOUNT'][0];
          $BEENHERE = 1;
  
          // Close used resources
          oci_free_statement($loginsql);
          oci_close($conn);
          }
      }
          ?&gt;
  </code></pre>
  
  <p>Here are my php settings in a png file: <a href="http://i.imgur.com/7c8BzZG.png?1" rel="nofollow">http://i.imgur.com/7c8BzZG.png?1</a></p>