Php incorrect response

Hey guys can you check out the script below for me for obvious errors, I am kind of new to php and I have been following a video tutorial on how to set up this shopping cart. The script always drops out on the else condition and the table elements definitely exist in the database doesn’t make sense. Have a feeling it has something to do with the preg_replace syntax.


//Parse the log in form if the user has filled it out and pressed “submit”
if(isset($_POST[“username”]) && isset($_POST[“password”])) {

$manager = preg_replace(‘#[^A-Za-z0-9]#i’,“”,$_POST[“manager”]); //filter everything but numbers and letters
$password = preg_replace(‘#[^A-Za-z0-9]#i’,“”,$_POST[“password”]); //filter everything but numbers and letters
//Run Mysql query to be sure that this person is an admin and that their password session var equals the database information
//connect to MYSQL database
$sql = mysql_query(“SELECT id FROM admin WHERE id=‘$managerID’ AND username=‘$manager’ AND password = ‘$password’ LIMIT 1”); // Query the person
//<-------------------------------MAKE SURE PERSON EXISTS IN DATABASE---------------------------->
$existCount = mysql_num_rows($sql); //count the row nums
if($existCount ==1){ //evaluate the count
while($row = mysql_fetch_array($sql)){
$id = $row[“id”];
$_SESSION[“id”] = $id;
$_SESSION[“manager”] = $manager;
$_SESSION[“password”] = $password;
} else{
echo’That information is incorrect! Try again <a href=“index.php”>CLick Here</a>';

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
<html xmlns=“”>
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8” />
<title>Store Home</title>
<link href=“…/style/style.css” rel=“stylesheet” type=“text/css” />

<div id=“mainWrapper”>
<?php include_once(“…/template_header.php”)?>
<div id=“Page Content”><h3>Please login before continuing:</h3>
<form id =“form1” name=“form1” action=“admin_login.php” method=“post”>
User Name:<br />
<input name = “username” id=“username” size=“40” type=“text” /><br />
Password:<br />
<input name= “password” id=“password” size=“40” type=“text” /><br />
<br /><br />
<input name= “button” id=“password” type=“submit” /><br />
<?php include_once(“…/template_footer.php”)?>

I haven’t seen on your form an input field with the name “manager”, so $_POST[“manager”] is undefined.

BTW, the type of a password input element should be “password”, and an id of an element should not be used more than once.