Location: PHPKode > projects > Tech Tickets > index_orig.php
<?php
//see if logged in
session_start();
if(isset($_SESSION["pid"])) {header("Location: default.php");}
/********************************8
LOGON INFO:
Logon authorization comes from p_people table
Cookies set:
-pid = p_people.pid (unique, non changing person id.  all other tables use this field as their foreign key)
-uid = p_people.userlogon (logon name, primarily used for legacy purposes)
-firstname = p_people.name_first + 1 letter of p_people.name_last (use for public displays, like message board etc)
-role = p_people.role (used for routing and permissions)
*/
//if not logged in, display the logon screen

   if ($_POST){
		$username = $_POST["username"];
		$pw = $_POST["pw"];
	
	   //see if user and password are ok
	   //set up connection to mysql database
	   //this script pulls the db connection info from db_def.php
	   include("include/connections.php");  //you must update this file for each project
	   mysql_select_db($database, $conn);
                   //first, get username out of moregroupware db
				   $qry_allowed = "SELECT * FROM tt_users WHERE ((email = '$username') and (password = '$pw'))";
				   $result_allowed = mysql_query($qry_allowed, $conn) or die(mysql_error());
				   if($my_row = mysql_fetch_array($result_allowed)) {
				   	//exists in client list of more groupware
						//username is found and password matches
                       //Start session and set cookie with userlogon
					   //session_start();
                       $_SESSION["uid"] = $username;
					   $_SESSION["pid"] = $my_row['UserID'];
                       $_SESSION["firstname"] = $my_row['FirstName'] . " " . $my_row['LastName'];

					   //we assume this person is a client, unless they exist in our ee table
					   		//moregroupware groupid 8=Technician
								if ($my_row['Role']=="T") {
								//tech
									$therole = "T";
								   $_SESSION["role"] = $therole;
								   $_SESSION["type"] = 'E';
								} else {
								//client
								   $therole = "U";
								   $_SESSION["role"] = $therole;
								   $_SESSION["type"] = 'C';
					   }
					   //redirect to secure index page based on role
					   //select case role...
                       	if (isset($whendone))
						{
							header("Location: $whendone");
						}else{
							if($therole=="T") { //technician
								header("Location: technician/default.php");
							}else{
								header("Location: default.php");
							}
						} //end if
                      //no user name found
                      }
                   else
                   {
						$badlogon = "Username or password incorrect.";
                   }
   }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>Logon</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
a:link, a:visited {
	color: #000099;
	text-decoration: none;
}
a:link:hover, a:visited:hover {
	color: #000099;
	text-decoration: underline;
}

-->
</style>
</head>

<body bgcolor="#999999" topmargin="0">

<table width="784" border="3" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
<tr bordercolor="#FFFFFF">
	<td colspan="3"><img src="images/banner.jpg"></td>
</tr>
<tr bordercolor="#FFFFFF">
	<td width="131" height="255" valign="top">
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
        <!--DWLayoutTable-->
        <tr>
          <td width="135" height="255" valign="top" bgcolor="#FFFFFF">
		  <br><br>
		 </td>
        </tr>
		</table>
	</td>
    <td width="512" valign="top">

      <h1 align="center"> <font face="Verdana, Arial, Helvetica, sans-serif">Logon</font>
      </h1>
	  <h3 align="center"><font color="#FF0000"><?php echo $badlogon; ?></font></h3>
  <FORM  action="index.php" method="POST">
  <input type="hidden" name="action" value="login">
        <table align="center" border="0" cellpadding="2" cellspacing="2">
          <tr>
            <td width="121" bgcolor="#999999"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Email
              address </font></strong></td>
            <td width="157" bgcolor="#CCCCCC"> <div align="center">
                <INPUT TYPE="TEXT"  name="username" align="middle" maxlength="50" style="background-color:#cccccc;width:100%;" onFocus="this.style.backgroundColor='#ffffcc'" onBlur="this.style.backgroundColor='#cccccc'" >
              </div></td>
          </tr>
          <tr>
            <td bgcolor="#999999"><strong><font color="#FFFFFF" size="2" face="Verdana, Arial, Helvetica, sans-serif">Password</font></strong></td>
            <td bgcolor="#CCCCCC"> <div align="center">
                <INPUT TYPE="password"  name="pw" align="middle" maxlength="20" style="background-color:#cccccc;width:100%;" onFocus="this.style.backgroundColor='#ffffcc'" onBlur="this.style.backgroundColor='#cccccc'" >
              </div></td>
          </tr>
          <tr bgcolor="#CCCCCC">
            <?php if(isset($whendone)) {
				//reset whendone
				?>
				<input type="hidden" name="whendone" value="<?php echo $whendone; ?>">
				<?php } ?>
            <td colspan="2">
              <div align="center">
                <INPUT TYPE="SUBMIT"  name="submit" value="Submit" align="middle">
              </div></td>
          </tr>
        </table>

        <div align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><a href="forgot_password.php">forgot
          password?</a></font> </div>
      </FORM>

      <p align="center">&nbsp;</p>
      <p align="left">&nbsp;</p>

</td>
    <td width="129" valign="top" bordercolor="#FFFFFF" bgcolor="#FFFFFF">
			  <p>
		  	<?php echo $welcome; ?>
		   </p>
	</td>
  </tr>
</table>
<table width="784" border="0" align="center" cellpadding="2" cellspacing="2">

</table>
<p align="center">&nbsp;</p>
</body>
</html>
Return current item: Tech Tickets