Hi there, below is the code I use to let users login to their control panel, however I would like there to be two different tables one for users and the other for employers.
How can I modify the code below to let users login to either the users profile or the employers profile ?
I’m Ok with probably using a check box and let users click off to where they want to login too or let the script direct them according to their username or password.
thanks!
<?php
if(isset($_POST['login']))
{
$uname=$_POST['username'];
$upass=$_POST['password'];
$querylogin=mysql_query("select * from userdata where username='$uname' and password='$upass'");
if(!$querylogin)
{
echo "Query Failed";
}
else
{
if(mysql_num_rows($querylogin) == 1)
{
$row=mysql_fetch_array($querylogin);
$status=$row['user_status'];
$activestatus=$row['status'];
$userid=$row['user_id'];
if($status == 1 && $activestatus== "Active" )
{
$_SESSION['user_name']=$uname;
$_SESSION['user_pass']=$upass;
$_SESSION['sess_adminid1']=$userid;
$_SESSION['sess_adminusername1']=$uname;
//echo "<meta http-equiv='refresh' content='0; URL=userprofile.php'>";
?>
<script language="javascript">
document.location.href='<?php echo SERVER_URL;?>user/';
</script>
<?php
}
else
{
echo "<div align=\\"center\\" style=\\"font-family:Verdana, Arial, Helvetica;font-size:12px;font-weight:900; background-color:#EF8E8E; padding:5px;\\">Your Account is not activated.Check your Inbox</div>";
}
}
else
{
echo "<div align=\\"center\\" style=\\"font-family:Verdana, Arial, Helvetica;font-size:12px;font-weight:900; background-color:#EF8E8E; padding:5px;\\">Username or Password Invalid</div>";
}
}
}
?>
<!------------>
<?php
if ((isset($_SESSION['user_name']) && $_SESSION['user_pass'] != "") || (isset($_SESSION['admin_upass']) && $_SESSION['admin_upass']!= ""))
{
}
else
{
?>
<div id="signup-form-form">
<form method="post" action="" name="login_form">
<table class="nom">
<tr>
<td><label for="inp-user">Username:</label></td>
<td colspan="2"><input type="text" name="username" id="username" style="margin:3px 0;" size="39" /></td>
</tr>
<tr>
<td><label for="inp-pass">Password:</label></td>
<td colspan="2"><input type="password" name="password" id="password" style="margin:3px 0;" size="39" /></td>
</tr>
<tr>
<td></td>
<td class="smaller"><input type="checkbox" name="" id="inp-remember" /> <label for="inp-remember" title="Remember me for 14 days" class="help">Remember</label></td>
<td class="t-right"> <input type="submit" name="login" value="Login" style="margin-top:2px;" /></td>
</tr>
</table>
</form>
</div> <!-- /signup-form-form -->
<div id="signup-form-bottom">
<p class="ico-send nom"><a href="">Forgot your password?</a></p>
</div> <!-- /signup-form-bottom -->
</div> <!-- /signup-form -->
<?php } ?> <?php ?>
</div> <!-- /top -->