Location: PHPKode > projects > Helpdesk Over Web > how/login.php
<?php

// Allows Users to login.

// Include Configuration File
require_once ('../how/includes/config.inc'); 

// Set the page title and include the HTML header.
$page_title = 'Helpdesk Over Web - Login';
include ('includes/header.html');

if (isset($_POST['submit'])) { // Check if the form has been submitted.
	// Connect to Database
	require_once ('includes/mysql_connect.php');
	
	// Retrieve username variables.
	$u = $_POST['username']	;
	$p = $_POST['password'];
	
	$query = "SELECT HOWLogin, FullName, Role FROM systemusers WHERE HOWLogin='$u' AND Password=PASSWORD('$p');";		
	$result = @mysql_query ($query);
	$row = mysql_fetch_array ($result, MYSQL_NUM); 
		
	if ($row) { // Follow this branch if a match was made.			
		// Create New Session, Session Variables.
		$_SESSION['LoggedInUser'] = $row[0];
		$_SESSION['FullName'] = $row[1];
		$_SESSION['Role'] = $row[2];

		// Retrieve settings from system config table.
		$sqlorgdetails = "SELECT OrgName, HelpdeskTel, HelpdeskEmail FROM sysconfig";
		$records = range(1, 500);
		$result = mysql_query($sqlorgdetails)
			   or die("Invalid query: " . mysql_error());
		list($orgname, $helpdesktel, $helpdeskemail) = mysql_fetch_row($result);

		$_SESSION['OrgName'] = $orgname;
		$_SESSION['HelpdeskTel'] = $helpdesktel;
		$_SESSION['HelpdeskEmail'] = $helpdeskemail;
		
		ob_end_clean(); 
		header ('Location: /how/index.php');
		exit();		

		} else { // Follow this branch if no match was made.
			echo "<p><font color='red' size='+1'>Username/Password Invalid!</font></p>"; 
		}
		
		// Close Database Connection
		mysql_close(); 
}

echo "<h1>Login Page</h1>
<p>Ensure that cookie support is enabled in your browser before logging in!</p>
<form action='../how/login.php' method='post'>
<table width='400'>
<tr align='bottom'><td align='bottom'><p><b>Login:</b></td><td align='bottom'><input type='text' name='username' size='17' maxlength='15' value='";
if (isset($_POST['username'])) echo $_POST['username'];
echo "'></td></tr>
<tr align='bottom'><td align='bottom'><p><b>Password:</b></td><td align='bottom'><input type='password' name='password' size='22' maxlength='20' /></td></tr>
</table>
<div align='left'><input type='submit' name='submit' value='Login' /></div>
</form>
<P><BR><P>";

// Include standard HTML footer.
include ('includes/footer.html');
?>
Return current item: Helpdesk Over Web