I am trying to take some login code and have it chk a field in the db to determine which page it sends them to on login. Here is what I have so far
<?php
session_start();
require_once("include/db.php");
$dbc = db_connect() or die(mysql_error());
$id = escape_data($_SESSION['id'],$dbc);
if (strlen($_POST['login'])) {
$username = escape_data($_POST['user'], $dbc);
if(strlen($_POST['user'])==0) {
$error=TRUE;
$msg='Please enter your username!';
} else {
$username = escape_data($_POST['user'],$dbc);
}
if(strlen($_POST['pass'])==0) {
$error=TRUE;
$msg='Please enter your password!';
} else {
$password = md5($_POST['pass']);
}
if($error != TRUE) {
$query="SELECT * from accounts WHERE username='$username' and password='$password' LIMIT 1";
$results = mysql_query($query) or die(mysql_error());
if(@mysql_num_rows($results) > 0) {
//Login valid
$row = mysql_fetch_array($results, MYSQL_ASSOC);
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $_POST['user'];
$_SESSION['password'] = $_POST['pass'];
header("location: clients/order.php");
} else {
$error=TRUE;
$msg = 'Invalid username/password!';
}
}
}
?>
I need it to chk the field First_name in the db for the user thats logs in so if first_name is empty send them to order if its not then send them to index
Thanks
Help with some login code with extra
Moderator: General Moderators