Hi, wish somebody can help me T_T I'm little bit confused how to make user log-in based on country or territory, what I'm talking about is like this: The User table is: id_user | username | password | level | id_country The Country table is: id | country_name And when user login, there's a data entry form and there is a drop-down/combo-box in a form, that filled with user countries, like this: Country: [____] --> This part is automatically filled/disabled field if a user log-in with their username based on level and countries. Province: [____] --> This is a chained combo-box from countries City: [____] --> Also this chained to Province What I mean is, when user's log-in with their country id, so the "Country Combo-Box" will be automatically filled and disabled. So user can't choose another country, only their country based on username and territories. Thank you for all your help. Best regards, Kris I have this scripts:
login_form.php
<div><center>
<form name="logForm" method="post" action="login_validation.php">
<table class="table-list" width="500" border="0" cellpadding="2" cellspacing="1" bgcolor="#999999">
<tr>
<td width="106" rowspan="5" align="center" bgcolor="#CCCCCC"><img src="images/padlock.png" width="116" height="75" /></td>
<th colspan="2" bgcolor="#CCCCCC"><b>LOGIN FORM </b></td>
</tr>
<tr>
<td width="117" bgcolor="#FFFFFF"><b>Username</b></td>
<td width="263" bgcolor="#FFFFFF"><b>:
<input name="txtUser" type="text" size="30" maxlength="20" />
</b></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><b>Password</b></td>
<td bgcolor="#FFFFFF"><b>:
<input name="txtPassword" type="password" size="30" maxlength="20" />
</b></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><b>Access Level</b></td>
<td bgcolor="#FFFFFF"><b>:
<select name="comboLevel">
<option value="BLANK">- Choose -</option>
<?php
$level = array("operator", "admin");
foreach ($level as $p) {
if ($_POST['comboLevel']==$p) {
$check="selected";
} else { $check = ""; }
echo "<option value='$p' $check>$p</option>";
}
?>
</select>
</b></td>
</tr>
<tr>
<td bgcolor="#FFFFFF"> </td>
<td bgcolor="#FFFFFF"><input type="submit" name="btnLogin" value=" Login " /></td>
</tr>
</table>
</form>
</center></div>
and this validation script: login_validation.php
<?php
if(isset($_POST['btnLogin'])){
$msgError = array();
if ( trim($_POST['txtUser'])=="") {
$pesanError[] = "Username </b> cannot empty !";
}
if (trim($_POST['txtPassword'])=="") {
$msgError[] = "Password </b> cannot empty !";
}
if (trim($_POST['comboLevel'])=="BLANK") {
$msgError[] = "Level</b> not picked !";
}
$txtUser = $_POST['txtUser'];
$txtUser = str_replace("'","´",$txtUser);
$txtPassword=$_POST['txtPassword'];
$txtPassword= str_replace("'","´",$txtPassword);
$comboLevel =$_POST['comboLevel'];
if (count($msgError)>=1 ){
echo "<div class='mssgBox'>";
echo "<img src='images/exclamation.png'> <br><hr>";
$noMsg=0;
foreach ($msgError as $index=>$show_msg) {
$noMsg++;
echo " $noMsg. $show_msg<br>";
}
echo "</div> <br>";
include "login.php";
}
else {
$loginSql = "SELECT * FROM user WHERE username='".$txtUser."'
AND password='".md5($txtPassword)."' AND level='$comboLevel'";
$loginQry = mysql_query($loginSql, $conndb)
or die ("Query Error : ".mysql_error());
if (mysql_num_rows($loginQry) >=1) {
$loginData = mysql_fetch_array($loginQry);
$_SESSION['SES_LOGIN'] = $loginData['id_user'];
$_SESSION['SES_USER'] = $loginData['username'];
if($comboLevel=="admin") {
$_SESSION['SES_ADMIN'] = "admin";
}
if($comboLevel=="operator") {
$_SESSION['SES_OPERATOR'] = "operator";
}
// Refresh
echo "<meta http-equiv='refresh' content='0; url=?page=Main-Page'>";
}
else {
echo "You Not Login As ".$_POST['comboLevel'];
}
}
}
?>
Thank you for all help.... T_T thank you..