<?php  
		$userNameVar = $_POST["userName"];  //used for keeping track of who is logged in and search.
		setcookie("usr",$userNameVar,time()+1209600);     
?>

<HTML>
<HEAD>
<TITLE></TITLE>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="000000" >
<?php
        
                                                                                  //The following code will not be seen
function Secure() { 
    /* 
        Make the connection to the database. The syntax is 
        odbc_connect( 'SYSTEM_DSN' , 'USER', 'PASSWORD' ); 
        $cnx will hold the 
        pconnect is used to establish a persistent database 
        connection to the Database until the procedure is completed. 
    */ 


    $cnx = odbc_connect( 'HelpDesk' , '', '' ); 
    if (!$cnx) 
		{ 
        Error_handler( "Error in odbc_connect" , $cnx ); 
    	} 
		$PasswordVarPlus="";		
		$formNameVar = $_POST["userName"];
		$userNameVar = $_POST["userName"];
		$password = $_POST["password"];

    // send a simple odbc query . returns an odbc cursor 
	 //	$cur= odbc_exec( $cnx, "SELECT ID,FirstName, LastName,PCatagory,describe,Resolution FROM data WHERE ID =$dataVar" ); 
 	$cur= odbc_exec( $cnx, "SELECT ID,User,Pass,HelpDeskAddress FROM accounts WHERE User ='$userNameVar'" );  

        // fetch the succesive result rows 
    while( odbc_fetch_row( $cur ) ) 
		{ 
      //  $nbrow++; 
		$ID= odbc_result( $cur, 1 ); // get the field "UserName" 
        $UserNameVarPlus= odbc_result( $cur, 2 ); // get the field "UserName" 
        $PasswordVarPlus= odbc_result( $cur, 3 ); // get the field "Password" 
		$HelpDeskAdde= odbc_result( $cur, 4 );
		}
		odbc_close( $cnx); 

	if (!$cur) 
		{ 
        Error_handler( "Error in odbc_exec( no cursor returned ) " , $cnx ); 
		odbc_close( $cnx); 
    	} 

		if ($password == "")
			{
			$password = "Wrong No Way ERROR eRoR OPS DID IT AGAIN Hopefully not one more time one two";
			}
			
  			if (( $password == $PasswordVarPlus ) && ( $formNameVar == $UserNameVarPlus))                                    //Set the Password and Username here -
   			{
			print "Double Secret Access Granted!<br>";
   			$webpage = $HelpDeskAdde;                               //Chosen web page
   			odbc_close( $cnx); 
   			$fp = fopen( $webpage, "r" ) or die ("Couldn't open $webpage") ;   //Open the page
          	
				while ( ! feof( $fp ) )                                                             //
            	{  
				print fgets( $fp, 1024 ) ; 
				}  
				}                                            //Display page in browser
  				else                                                                                            //If password or Username incorrect
   				{
   				echo "<br><br>";                                                                        //Display and error message and
   				echo "<p align=center>" ;                                                            //instructions
   				echo "<b>Authentication Failed<br><br>Please hit your 'Back' button and try again.</b>" ; 
   				echo "</p>" ;
   				}
}

Secure();
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p align="center"><a href="http://www.quickintranet.com"><img src="http://www.quickintranet.com/infosec/quickintranet-com.jpg" border="0"></a><br>
  CopyRight 2004<br>
  QuickIntranet.com<br>
  <a href="http://www.quickintranet.com">http://www.QuickIntranet.com </a></p>
