Hi There -
Am working on my final project for my PHP class (an ecommerce application) and a page that I wrote a couple weeks ago, that worked just fine last week, isn't working anymore.
I know that I used it to work from for a different kind of login page, so I could have messed it up then somehow. I have so much work ahead of me and I thought this was okay and I have no clue what's going on and I've been working for five hours on this one page and I just can't see anything anymore and my head really hurts.
But the page is very tidy.
Here's what's going on:
When I log in and click enter, I get a completely fresh login screen again.
I've tested the connection include on other files and it's fine.
Please help me!
(If you have any other helpful ideas to make my code more presentable, clear, clever, etc., I'd love to hear them.)
Thanks, -Lee
<?php session_start(); ?>
<html>
<!-- this got errors no matter where I put it: <?php header("Cache-Control:no-cache"); ?> -->
<!-- Employee Table Structure: | Emp_ID | Emp_Fname | Emp_Lname | Emp_Password | Emp_Email |-->
<body bgcolor= "#6da9dc" text="#551a8b">
<div align="center">
<br><br><br><br>
<?php
/*****************************************************************************\
Login Page that sends info to itself
\*****************************************************************************/
/************************ IF THE PASSWORD HAS ALREADY BEEN ENTERED ************/
if (isset($entered_Password))
{
include("includes/connect2db.php");
$sqlString="SELECT Emp_Password from employee where Emp_Lname ='$Emp_Lname'";
$result=mysql_query($sqlString,$con);
$row = mysql_fetch_assoc ($result);
$Emp_Password = ($row["Emp_Password"]);
echo "<br><br>";
echo "$Emp_Password<br>";
echo "$Emp_Fname <br>";
echo "$Emp_Lname <br>";
/************************ IF LOGIN INFO IS CORRECT ****************************/
if ($entered_Password == $Emp_Password AND ($Emp_Fname != NULL OR $Emp_Lname != NULL)) {
echo "**Login Successful** <br><br>";
// REGISTER SESSION VARIABLES
session_register("Emp_Fname");
session_register("Emp_Lname");
echo("You are logged in as $Emp_Fname $Emp_Lname. <br><br>");
include("includes/menu.php");
}
/************************ IF LOGIN INFO IS INCORRECT ***************************/
else if ($entered_Password !== $Emp_Password) {
echo ("<b>**Login Failed**</b><br><br>Please Try Again<br><br>");
?>
<form method="post" action="<?php echo($PHP_SELF); ?>" >
<table>
<tr>
<td align='right'>First Name: </td><td><input type="text" name="Emp_Fname" size="10"></td>
</tr>
<tr>
<td align='right'>Last Name: </td><td><input type="text" name="Emp_Lname" size="10"></td>
</tr>
<tr>
<td align='right'>Password: </td><td><input type="password" name="entered_Password" size="10"></td>
</tr>
<tr>
<td align='right'><input type="submit" value="Login"> </td><td> <input type="reset" value="Clear"></td>
</tr>
</table
</form>
<?php
}
}
/************************ IF NO PASSWORD ENTERED YET (FRESH LOGIN SCREEN) *****/
else {
echo "<b>**Please Log In**</b>";
?>
<form method="post" action="<?php echo($PHP_SELF); ?>" >
<table>
<tr>
<td align='right'>First Name: </td><td><input type="text" name="Emp_Fname" size="10"></td>
</tr>
<tr>
<td align='right'>Last Name: </td><td><input type="text" name="Emp_Lname" size="10"></td>
</tr>
<tr>
<td align='right'>Password: </td><td><input type="password" name="entered_Password" size="10"></td>
</tr>
<tr>
<td align='right'><input type="submit" value="Login"> </td><td> <input type="reset" value="Clear"></td>
</tr>
</table
</form>
<?php
}
?>
</div>
</body>
</html>