Location: PHPKode > projects > Moers - Event Registration System > moers-1.046/eventregistered.php
<?php
/************************************************************************************
    Copyright © 2008 xhub.com

    Bill Bennert
    5 Hooksett Tpke
    Bow, NH 03304-4414
    hide@address.com

    This file is part of the SCCNH Online Registration System.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Any system sensitive data such as IP addresses, usernames, and passwords 
    must be removed from this file before distribution.

************************************************************************************/

include 'include/config.php';
include 'include/functions.php';
include 'include/download.php';

// Connects to your Database
mysql_connect($database_IP, $database_Username, $database_Password) or die(mysql_error());
mysql_select_db($database_Name) or die(mysql_error());

//checks cookies to make sure they are logged in
if(isset($_COOKIE['SCCNH_ID']))
{
  $hashUsername = $_COOKIE['SCCNH_ID'];
  $sessionId = $_COOKIE['SCCNH_Session_ID'];

  $check = mysql_query("SELECT * FROM users WHERE user_hash = '$hashUsername'")or die(mysql_error());
  while($info = mysql_fetch_array( $check ))
  {
    $username = $info['username'];
    //if the cookie has the wrong sessionId, they are taken to the login page
    if ($sessionId != $info['session_id'])
    {
      header("Location: logout.php");
    }

    //otherwise they are shown the admin area
    else
    {
      changeCookie(); // Keep the session ID changing

      $eventDB = $_POST['regEventName'];
      if (isset($_POST['downloadEntries']))
      {
        downloadEntries($_POST['regEventKey']);
      }
      else if (isset($_POST['downloadMember']))
      {
        downloadMember($_POST['regEventKey']);
      }
      else if (isset($_POST['downloadPrintable']))
      {
        downloadPrintableList($_POST['regEventKey']);
      }
      else if (isset($_POST['showRegistration']))
      {
        include 'header.php';

        // Display events
        $eventcheck = mysql_query("SELECT * FROM events WHERE eventDB='$eventDB'") or die(mysql_error());
        echo "<h2>Event:</h2>";
        echo "<table border=\"1\">";
        echo "<tr><td>Event Name</td><td>Event Location</td><td>Event Date</td><td>Pre-registered</tr>";
        while($eventinfo = mysql_fetch_assoc( $eventcheck ))
        {

          echo "<tr>";
          echo "<td>".$eventinfo['eventName']."</td>";
          echo "<td>".$eventinfo['eventLocation']."</td>";
          echo "<td>".$eventinfo['eventDate']."</td>";
          echo "<td>";
    
          $tempquery = "SELECT * FROM ".$eventDB;
          $tempEventcheck = mysql_query($tempquery) or die(mysql_error());
          $reg_count = 0;
          $userRegistered = 0;
          while ($tempEventInfo = mysql_fetch_assoc( $tempEventcheck ))
          {
            $reg_count = $reg_count + 1;
            if ($tempEventInfo['registeredUser'] == $info['username'])
            {
              $userRegistered = 1;
            }
          }
          echo $reg_count;
          echo "</td>";
          echo "</tr>";
        }
        
        echo "</table><br>";
        echo "<hr><h2>Registered Users:</h2>";
        $regUsercheck = mysql_query("SELECT * FROM $eventDB ORDER BY `$eventDB`.`vehicleClass`")or die(mysql_error());
        echo "<table border=\"1\">";
        echo "<tr><td>SCCNH Class</td><td>Car Number</td><td>First Name</td><td>Vehicle</td><td>SCCA Class</td></tr>";
        while ($reguserinfo = mysql_fetch_assoc( $regUsercheck ))
        {
          $tempRegUser = $reguserinfo['registeredUser'];
          $tempRegQuery = "SELECT * FROM users WHERE username='$tempRegUser'";
          $tempusercheck = mysql_query($tempRegQuery);
          if($tempinfo = mysql_fetch_array( $tempusercheck ))
          {
            echo "<tr>";
            echo "<td>".$reguserinfo['vehicleClass']."</td>";
            echo "<td>".$reguserinfo['vehicleNumber']."</td>";
//            echo "<td>".$tempRegUser."</td>";
            echo "<td>".$tempinfo['fname']."</td>";
            
            $tempRegVeh = $reguserinfo['vehicleKey'];
            $tempRegQuery = "SELECT * FROM vehicles WHERE vehicleID='$tempRegVeh'";
            $tempvehcheck = mysql_query($tempRegQuery);
            if($tempvehinfo = mysql_fetch_array( $tempvehcheck ))
            {
              echo "<td>".$tempvehinfo['year']." ".$tempvehinfo['make']." ".$tempvehinfo['model']."</td>";
              echo "<td>".$tempvehinfo['scca_class']."</td>";
//              echo "<td>".$tempvehinfo['sccnh_class']."</td>";
            }

            echo "</tr>";
          }
        }
        echo "</table>";
        echo file_get_contents("footer.html");
      }	
    }
  }
}
else

//if the cookie does not exist, they are taken to the login screen
{
header("Location: logout.php");
}
?>
Return current item: Moers - Event Registration System