<?php
ini_set('display_errors','off');
error_reporting(E_ALL);
// extract($_POST);
extract($_POST);
                extract($_SESSION);
                extract($_COOKIE);
 
session_start();


//extract($_SESSION);


include("admin/config.php");

include( "admin/settings.inc.php");

// login
if ($email && $password)
	{
		// If the user has just tried to log in
		$passwd = md5($password);
		$query = "select * from ".$prefix."store_customer where email='$email' and password=('$passwd')";
		$result = mysql_query($query);
  
		if (mysql_num_rows($result) >0 )
			{
				// if they are in the database register the user for the session
				$valid_user = $email;
				//session_register("valid_user");
				$_SESSION[valid_user]=$valid_user;

			} // end if (mysql_num_rows($result) >0 )
		else
			{
				// they have not tried to log in yet or have logged out
				$error_message = "<p align='center'><font color=#990000><b>$la_account_login_error</b></font></p>";
			}// end else

}// end if ($email && $password)

if (isset($_SESSION[valid_user]))
	{
		echo "<Script language=\"javascript\">window.location=\"$site_url/control_panel.php\"</script>";
	}

include( "header.inc.php");

include( "shoppingcart.php");
$cart = new Cart;

include("subheader.inc.php");

include("menu.inc.php");

// start border
sb("100%",$la_account_login,$colour_1,$bg_colour);

// store navigation
echo"<a href=\"index.php\" target=\"_self\">$la_search_home</a> > $la_account_login<br>";

echo$error_message;

// if no session is registered
if (!isset($_SESSION[valid_user]))
	{

		// display login form
		echo"<br><form method=\"post\" action=\"login.php\">
		<table align=\"center\" width=\"550\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
			<tr>
				<td bgcolor=\"$colour_2\">
					<table cellpadding=\"2\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">
						<tr bgcolor=\"$colour_1\">
							<td width=\"100%\" colspan=\"2\" height=\"20\" background=\"images/bevel_bg.gif\">$la_account_login_below</td>
						</tr>
						<tr bgcolor=\"$colour_1\"> 
							<td width=\"45%\"><b>$la_account_username:</b></td>
							<td width=\"55%\"><input name=\"email\" class=\"textbox\" type=\"text\" size=\"25\" maxlength=\"40\"></td>
						</tr>
						<tr bgcolor=\"$colour_1\"> 
							<td width=\"45%\"><b>$la_account_password:</b></td>
							<td width=\"55%\"><input name=\"password\" class=\"textbox\" type=\"password\"name=\"password\" size=\"25\" maxlength=\"40\"></td>
						</tr>
						<tr bgcolor=\"$colour_1\"> 
							<td width=\"45%\">&nbsp;</td>
							<td width=\"55%\"><a href=\"forgot_pass.php\" target=\"_self\">$la_account_i_fog_pass</a><br>
							<a href=\"register.php\" target=\"_self\">$la_new_customer</a><br><br><input type=\"submit\" name=\"submit\" class=\"submit\" value=\"$la_account_login\"></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>";   

	}//end if session is not registered

// include end border
eb($bg_colour,$colour_1);

include("subfooter.inc.php");

include("footer.inc.php");

?>