Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/shop/login.php
<?php
session_start();
/*
asaancart - easy shopping cart solution
---------------------------------------

Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com

This file is part of asaancart - open source easy shopping cart solution.

asaancart is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

asaancart is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with asaancart.  If not, see <http://www.gnu.org/licenses/>.

*/

include("../config/config.php");
include("classes/functions.php");

if (session_id() == "") session_start();
$session_id = session_id();
$login_chk = "no";
$title = "Login / Register";

//list brands:

$sql = "SELECT * FROM brands ORDER BY brand_name";
$results = mysql_query($sql);
$total_brand = mysql_num_rows($results);
$smarty->assign('total_brand', $total_cat);

while($row = mysql_fetch_assoc($results) )
{
	$all_brands[] = $row;		
}

$smarty->assign('all_brands', $all_brands);

/// end list brands

//list categories:

$sql = "SELECT * FROM category ORDER BY category_name";
$results = mysql_query($sql);
$total_cat = mysql_num_rows($results);
$smarty->assign('total_cat', $total_cat);

while($row = mysql_fetch_assoc($results) )
{
	$cat_list[] = $row;		
}

$smarty->assign('cat_list', $cat_list);

/// end list categories

//list parent categories
$smarty->assign('cat_parent_list', menu_shop_by_category()); 
//end parent cat

$smarty->assign('title',$title);
$smarty->assign('page_heading',$title);

///get post vars
$email_address = $_POST['email_address'];
$confirm_email_address = $_POST['confirm_email_address'];
$password = $_POST['password'];
//end post vars


$customer_ref = rand(1000000000,9999999999);


///login start
if($_POST['register']=="Register")
{	
		//
		
		
		
				$email_address = $_POST['email_address'];
				$password = $_POST['password'];
				$sql_login_chk = "SELECT * FROM customers WHERE email_address='$email_address'";
				$results_login_chk = mysql_query($sql_login_chk);
				$total_login_chk = mysql_num_rows($results_login_chk);
						if($total_login_chk>0){
							$smarty->assign('register_msg',"ERROR: This email address is already registered with us, please select different email address.");
					
				}else{
				
				//inser into customer table 
					if($email_address!="" && $password!=""){
						
						$sql = "INSERT INTO customers (customer_ref, email_address, password) VALUES ('$customer_ref, ','$email_address', '$password')";
						$results = mysql_query($sql);
						$login_chk = "yes";
						
						$_SESSION['customer_ref'] = $customer_ref;
						$_SESSION['login_chk'] = $login_chk;
						header("location: confirm_items.php");
					}
				}// end if count chk
				
			//
}elseif($_POST['login']=="Login"){
				
				$email_address = $_POST['email_address'];
				$password = $_POST['password'];
				$sql_login_chk = "SELECT * FROM customers WHERE email_address='$email_address'";
				$results_login_chk = mysql_query($sql_login_chk);
				$total_login_chk = mysql_num_rows($results_login_chk);
				while($row = mysql_fetch_assoc($results_login_chk) )
				{
					$customer_ref = $row['customer_ref'];
				}
					
						if($total_login_chk>0){
						
						$login_chk = "yes";
						
						$_SESSION['customer_ref'] = $customer_ref;
						$_SESSION['login_chk'] = $login_chk;
						header("location: confirm_items.php");
					
				}else{
				$smarty->assign('login_msg',"ERROR: Invalid email address or password. Please re-enter email address and password.");
				}
				
				
				
}
//end login
$smarty->display('site_login.tpl');
?>
Return current item: Simple PHP Shopping cart - asaancart