linuxfront-v2-logistics/index2.php
index2.php is the legacy customer login page for the Comprehensive Freight Management System. It initializes the environment, handles authentication, and renders the right-hand navigation panel (login form or account links). Upon successful login, it redirects users to welcome.php.
Dependencies ⚙️
- inc/config.php
Bootstraps sessions, error handling, constants (paths, emails), and third-party libs. - getFlashData()
Retrieves “flash” messages stored in session for one-time display. - loginCustomer()
Authenticates credentials against the database; returns['ok' => bool, 'msg' => string]. - inc/panels/right_nav2.php
Renders the right panel: login form when not authenticated, or account menu when logged in. - welcome.php
Landing page post-login.
Workflow 🔄
- Initialization
- Include
inc/config.php. - Start or resume session.
- Include
- Session Check
- If
$_SESSION['Customer_ID']exists, redirect towelcome.php.
- If
- Flash Message
- Call
getFlashData()and store any message in$message.
- Call
- Form Submission
- On
POSTwithaction, readusr_emailandpwd. - Hash password:
md5($_POST['pwd']). - Invoke
loginCustomer($email, $pwd, false, 'tech_logistics_access', $_POST['pwd']). - On success, redirect to
welcome.php; on failure, display error.
- On
Key Variables 📋
| Variable | Type | Description |
|---|---|---|
$message |
string | HTML-safe message to display (flash or error). |
$msg |
array | Raw array returned by getFlashData(). |
$email |
string | User-submitted email/username. |
$pwd |
string | MD5-hashed password. |
$status |
array | Result from loginCustomer(), with ok and msg. |
Core PHP Logic 🔑
<?php
include_once("inc/config.php");
// 1. Redirect if already logged in
if (!empty($_SESSION['Customer_ID'])) {
header("location:welcome.php");
exit;
}
// 2. Prepare message
$message = " ";
$msg = getFlashData();
if (!empty($msg)) {
$message = $msg['msg'];
}
// 3. Handle login form submit
if (isset($_POST['action']) && $_POST['action'] != '') {
$email = $_POST['usr_email'];
$pwd = md5($_POST['pwd']);
$status = loginCustomer($email, $pwd, false, 'tech_logistics_access', $_POST['pwd']);
if ($status['ok']) {
header("location:welcome.php");
exit;
} else {
$message = $status['msg'];
}
}
?>
HTML Structure 🎨
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- < ? // include_once(TEMPLATE_DIR . "inc/template_meta.php"); ?> -->
</head>
<body>
<div id="wrapper">
<div id="theme_bg">
<!-- < ? // include_once("inc/panels/header.php"); ?> -->
<div id="content_wrap">
<h2 class="news">Comprehensive Freight Management System</h2>
<div id="content">
<? include_once("inc/panels/right_nav2.php"); ?>
</div>
</div>
</div>
<div id="footer_one">
<!-- < ? // include_once("inc/panels/footer.php"); ?> -->
</div>
<br clear="all" />
</div>
</body>
</html>
Right-Hand Panel: right_nav2.php 🛠️
This panel adapts based on login state:
-
If logged in:
Displays Manage Your Account menu with links:- My Account
- Quote & Ship
- My Shipments
- Address Book
- Product Catalog
- Create BOL
- Locations
- Apply For Credit
- Track Shipment
-
If not logged in:
Renders a customer login form posting back toindex2.php:<form id="lgnfrm" action="index2.php" method="post"> <input type="hidden" name="action" value="login" /> <table> <tr><td>Username / Email</td></tr> <tr><td><input type="text" name="usr_email" class="login_input" /></td></tr> <tr><td>Password</td></tr> <tr><td><input type="password" name="pwd" class="login_input" /></td></tr> <tr> <td> <input type="submit" value="Login" /> <div style="color:#F00;"><?=$message?></div> </td> </tr> <tr> <td> <ul> <li><a href="forgot_password.php">Forgot your password?</a></li> <li><a href="signup.php">Create an account</a></li> </ul> </td> </tr> </table> </form>
Configuration: inc/config.php 📦
- Starts PHP session and sets HTTP headers.
- Defines constants like
TEMPLATE_DIR,SITE_PATH, email addresses, profiling flags. - Loads Google Authenticator and other libraries.
- Manages environment-specific settings (production vs. localhost).
Summary ✨
index2.php is a lightweight, single-purpose login gateway. It relies on a central configuration, flashes feedback messages, leverages a shared authentication function, and defers all UI to a reusable panel (right_nav2.php). Upon authentication, it directs users to the secured welcome dashboard.