Ok I have a question and I know it can be done but I am having a brain block. I have a database with users that are active or not with type of user they are (ie: contractor, architect, engineer, and owner). What I want to do is when they log in the login checks the database to see if the user name, password, email and active are present that is true. It presents an error if the users account has been deactivate. What I want to do is if these are all true then go to the area of the web site that is dedicated just for that type of user from the database.
<?php
//log in page
include('init.php');
include'../customer/cust_temp/header.php';
?>
<form action="" method="post">
<p>
Email: <input type="email" name="login_email" />
User Name:<input type="text" name="user_name" />
Password: <input type="password" name="login_password" />
<input type="submit" value="Log in"/>
</p>
</form>
<div id="register"><a href="register.php" id="register">Register New User</a></div>
<?php
if(isset($_POST['login_email'], $_POST['user_name'], $_POST['login_password'])){
$login_email = $_POST['login_email'];
$user_name = $_POST['user_name'];
$login_password = $_POST['login_password'];
$errors = array();
if (empty ($login_email) || empty ($user_name) || empty($login_password)){
$errors[] = 'Email, user name and password required';
}else if (user_active($user_name) === false){
$errors[] = 'You have\'t activated your account!';
}else{
$login = login_check($login_email, $user_name, $login_password);
if($login === false){
$errors[] ='Unable to log you in';
}
}
if (!empty ($errors)){
//loop thru errors and place each into a single error
foreach ($errors as $error){
echo $error,'<br />';
}
}else{
//log user in
$_SESSION['contact_id'] = $login;
if(user_page($type_of_contact)==1){
echo '$type_of_contact';
header ('Location: accountinactive.html');
}elseif(user_page($type_of_contact)==2){
header ('Location: test.php');
}elseif(user_page($type_of_contact)==3){
header('');
}else{
header ('Location: ../customer/index.php');
exit();
}
}
}
include '../customer/cust_temp/footer.php';
?>
This is my function page.
If anyone has any suggestion of how to structure this I would be greatly appreicate.
Thanks
Jon