I'm not receiving any errors, but the below code is rejecting my username and password. I have the username and password that I'm using echoed when prompted to login the second time and the it is correct. I'm not sure why this is not working.
Any ideas?
<?php
session_start();
include("common.php");
include("sql_layer.php");
include("functions.php");
include("header.php");
if(!isset($_POST["email"])){
?>
<?php head(); ?>
<form method="Post" action="<?=$_SERVER['PHP_SELF']?>?mod=<?php echo $_GET['mod'];?>">
<span class="name_text">Login. <br/></span>
e-mail:
<br/>
<input class="login_field" type="text" name="email" />
<br/>
<br/>
password:
<br/>
<input class="login_field" type="password" name="pwd" />
<br/>
<br/>
<input class="login_button" type="submit" name="submitok" value="Sign in">
</form>
<?php
exit;
}
$_SESSION["email"] = $_POST['email'];
$_SESSION["pwd"]= $_POST['pwd'];
//connect to database
dbConnect('crc');
$email = $_POST['email'];
$password = $_POST['pwd'];
$pass = md5('$password');
$sql = "SELECT * FROM tblusers WHERE emailaddress = '$email' AND password = '$pass'";
$result = mysql_query($sql) or die ("Error in query: $sql. " . mysql_error());
if (sql_num_rows($result) == 0) {
?>
<?php head(); ?>
<body style="background-color: #CCCC99; text-align: center">
<?php echo $_POST['email'];?>
<br/>
<?php echo $passw= $_POST['pwd']; ?>
<br/>
<form method="Post" action="<? $_SERVER['PHP_SELF']?>?mod=<?php echo $_GET['mod'];?>">
<span class="name_text">Login.<br/></span>
<div style="width: 200px; padding: 3px; border-style: solid; border-width:1px; border-color: #999999; background-color: #E9E9E9;color:#FF0000;">You have entered an incorrect username or password.Please try again. </div>
<br/>
e-mail:
<br/>
<input class="login_field" type="text" name="email" />
<br/>
<br/>
password:
<br/>
<input class="login_field" type="password" name="pwd" />
<br/>
<br/>
<input class="login_button" type="submit" name="submitok" value="Sign in">
</form>
</body>
<?php
exit;
}
$roleid = mysql_result($result,0,"role_id");
?>