
PK 
<?php
session_start();
require_once 'common/common.php';
$errorMessage = '';
if (isset($_POST['username']) && isset($_POST['password']))
{
if($_POST['city']=="amritser")
{
mysql_connect("localhost","root","tree") or die('Could not connect to Server');
mysql_select_db("pcfcindi_newamritsar") or die('database not found');
}
else if($_POST['city']=="ludhiana")
{
mysql_connect("localhost","localhost","tree") or die('Could not connect to Server');
mysql_select_db("pcfcindi_newludhiana") or die('database not found');
}
$tname = $_POST['username'];
$Password1 =md5($_POST['password']);
// check if the user id and password combination exist in database
$sql = "SELECT user,id
FROM amembs
WHERE user = '$tname'
AND pass =('$Password1')";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1)
{
// the user id and password match,
// set the session
$idc=mysql_fetch_array($result);
$_SESSION['city'] = $_POST['city'];
$_SESSION['user_id'] = $idc['id'];
$_SESSION['str_sessid']="ZG93bmxvYWRmaWxlc2hhc2gvMQ";
$din=date('D, d M Y + H:i:s a');
$sql = "UPDATE amembs
SET lastlogin='$din'
WHERE user = '$tname'
AND pass =('$Password1')";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
// after login we move to the main page
header('Location: members_area.php');
// exit;
}
else
{
$errorMessage = '<span style="color:red;">Sorry, wrong username or password</span>';
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>PEST CONTROL AND FUMIGATION COMPANY - MEMBERS LOGIN</title>
<link rel="stylesheet" type="text/css" href="template.css" media="screen" />
<link rel="stylesheet" type="text/css" href="template2.css" media="screen" />
<link rel="stylesheet" type="text/css" href="content.css" media="screen" />
<link rel="stylesheet" type="text/css" href="portal-page.css" media="screen" title="Dalvay"/>
<script language="JavaScript" type="text/javascript" src="common/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function(){
$('#submit').click(function(){
if($('#username').val()=="")
{
alert("Please Enter Valid User Name.");
$('#username').focus();
return false;
}
if($('#password').val()=="")
{
alert("Please Enter Password");
$('#password').focus();
return false;
}
});
});
</script>
</head>
<body id="central" class="portal-page">
<div class="portal-box">
<div class="portal-box-interior">
<div class="portal-box-header">
<h1>
Members Login...
</h1>
</div>
<img src="bulk_mid.jpg" align="right" height="190">
<div class="portal-box-contents">
<form action="" method="post">
<?php echo $errorMessage; ?>
<div class="corner-box">
<strong>Username >> </strong>
<input type="text" name="username" id="username" size="25" maxlength="30">
<br><br>
<strong>Password >> </strong>
<input type="password" name="password" id="password" size="25" maxlength="30">
<br><br>
<strong>Branch >> </strong>
<select name="city">
<option value="amritser">Amritsar</option>
<option value="ludhiana">Ludhiana</option>
</select>
<br/><br/>
</div>
<center>
<span class="portal-button">
<input type="submit" class="amo-submit" id='submit' onclick="return validate();" value=" Login into Members Area >>">
</span>
</center>
</form>
</div> <!-- end .portal-box-contents -->
</div> <!-- end .portal-box-interior -->
</div> <!-- end .portal-box -->
<hr />
<!-- start #footer -->
<div id="footer">
<p dir="ltr">copyrights © 2009–2010 Anibs Management Solutions</p>
</div>
<!-- end #footer -->
</body>
</html>


PK 99