Authentication form:
<!-- BEGIN Page is index.php -->
<form action="includes/user_login_action.php" method="post">
<table border="1" align="left">
<tr><td class="blackBoldTen">Login Here</td></tr>
<tr>
<td class="blackBoldTen">Username: <input type="text" name="username"></td>
</tr>
<tr>
<td class="blackBoldTen">Password: <input type="password" name="password"></td>
</tr>
<tr>
<td><input type="submit" name="submit" value="Log In" class="blackBoldTen"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<!-- END Page is index.php -->
USER_LOGIN_ACTION Page:
<!-- BEGIN Page is includes/user_login_action.php-->
<?php
if(isset($POST["submit"])) {
if(strlen(trim($POST["username"])) > 0) {
if(strlen(trim($_POST["password"])) > 0) {
require("db.inc.php");
$c = @db_connect();
$q = "SELECT EMPID, ROLE_ID, USERNAME, PASSWORD, FNAME, LNAME, EMAIL FROM EMPLOYEE WHERE ";
$q .= "username=" . "'" . htmlspecialchars(addslashes($_POST["username"])) . "'" . " AND ";
$q .= "password=" . "'" . sha1($_POST["password"]) . "'";
$s = ociparse($c, $q);
if (!$s){
die("Database troubles</body></html");
}
ociexecute($s, OCI_DEFAULT);
ocifetch($s);
$EMPID = ociresult($s, "EMPID");
$USERNAME = ociresult($s, "USERNAME");
$PASSWORD = ociresult($s, "PASSWORD");
$FNAME = ociresult($s, "FNAME");
$LNAME = ociresult($s, "LNAME");
$EMAIL = ociresult($s, "EMAIL");
$ROLE = ociresult($s, "ROLE_ID");
if (addslashes($_POST["username"]) == $USERNAME and sha1($_POST["password"]) == $PASSWORD) {
if (sha1($_POST["password"]) != $PASSWORD) {
echo "Password incorrect!";
exit;
}
if ($_POST["username"] != $USERNAME) {
echo "Username incorrect!";
exit;
} else {
oci_close($c);
session_start();
session_regenerate_id();
$_SESSION["EMPID"] = $EMPID;
$_SESSION["USERNAME"] = $USERNAME;
$_SESSION["PASSWORD"] = $PASSWORD;
$_SESSION["FNAME"] = $FNAME;
$_SESSION["LNAME"] = $LNAME;
$_SESSION["EMAIL"] = $EMAIL;
$_SESSION["ROLE"] = $ROLE;
// echo "this is the empid " . $_SESSION["EMPID"];
// echo "<br />";
//echo "this is the username " . $_SESSION["USERNAME"];
//$fname = $_SESSION["FNAME"];
//echo "Me FIRST name is " . $fname . "<br />";
header("Location: http://myserver/ctcadp/launch.php");
}
}
else {
echo "Login failed please try again. ";
}
} else {
echo " You must enter a password.";
}
} else {
echo "You must enter a username. ";
}
}
?>
<!-- END Page is include/user_login_action.php -->
Include file new_header for launch.php:
<!-- BEGIN Page is include/new_header_top.php -->
<?
session_start();
if (session_id() != "") {
$fullname = $SESSION["FNAME"] . " " . $_SESSION["LNAME"];
}
if (!empty($fullname)) {
echo "Welcome " . $fullname;
} else {
echo "Welcome Guest User";
}
?>
<!-- END Page is include/new_header_top.php -->
Launch.php Page:
<!--BEGIN this is launch.php -->
<?
session_start();
$title = "CTC ADP Listings";
include_once('includes/new_header_top.php');
include_once ("includes/adp_nav.php");
?>
<div id="launch">
<ul>
<li><b>ADP</b> - Provides options to browse and search for ADP equipment and related items.</li>
<li><b>SUPPLIES</b> - Provides options to browse and search for ADP Supplies.</li>
<li><b>SOFTWARE</b> - Provides options to browse and search for software used by CTC.</li>
<li><b>HELPDESK</b> - Provides a form to make a request for help and access to CTC FAQ's.</li>
</div>
</body>
</html>
<!--BEGIN this is launch.php -->
This is the error I get when I log in.
Notice: A session had already been started - ignoring session_start() in /usr/local/apache2/htdocs/ctcadp/includes/new_header_top.php on line 2
Notice: Undefined index: FNAME in /usr/local/apache2/htdocs/ctcadp/includes/new_header_top.php on line 4
Notice: Undefined index: LNAME in /usr/local/apache2/htdocs/ctcadp/includes/new_header_top.php on line 4