Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/admin/settings.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("includes/chk_login_status_inc.php");

$smarty->assign('title','Account Settings');

$store_id = 1;//$_POST['store_id'];
$store_title = $_POST['store_title'];
$b_name = $_POST['b_name'];
$b_abn = $_POST['b_abn'];
$b_address = $_POST['b_address'];
$b_email_address = $_POST['b_email_address'];
$b_phone = $_POST['b_phone'];
$b_fax = $_POST['b_fax'];
$b_state = $_POST['b_state'];
$b_country = $_POST['b_country'];
$o_fullname = $_POST['o_fullname'];
$o_email_address = $_POST['o_email_address'];
$old_password = $_POST['old_password'];
$new_password = $_POST['new_password'];
$password2 = $_POST['password2'];

$google_analytics_id = $_POST['google_analytics_id'];

$store_currency_m = $_POST['store_currency'];
$tax_rate = $_POST['tax_rate'];

if($_POST['btn_submit']=="Save")
{	
	$sql = "SELECT * FROM store_settings WHERE store_id=".$store_id;
	$results = mysql_query($sql);
	$total_res = mysql_num_rows($results);
	if($total_res>0){
		$sql = "UPDATE store_settings SET store_title='$store_title', b_name='$b_name', b_abn='$b_abn', b_address='$b_address', b_email_address='$b_email_address', b_phone='$b_phone', b_fax='$b_fax', b_state='$b_state', b_country='$b_country', o_fullname='$o_fullname', o_email_address='$o_email_address', tax_rate=$tax_rate, currency='$store_currency_m', google_analytics_id='$google_analytics_id' WHERE store_id=$store_id";
		$results = mysql_query($sql);
		$smarty->assign('msg', "<span>Done, new settings saved successfully</span>");
	}else{
		$smarty->assign('msg', "<span style='color:red'>Sorry, this store ID is invalid, please contact your system administrator</span>");
	}//page cnt	
	
	if($old_password!=""){
		if($new_password==$password2){
			$sql = "SELECT * FROM auth_user_admin WHERE username='".$_SESSION['username']."' AND password='".md5($old_password)."'";
		$results = mysql_query($sql);
		$num_row = mysql_num_rows($results);
		if($num_row==0){
			$smarty->assign('msg', "<span style='color:red'>Your username and password combination is incorrect, so please try again. Remember that the password field is case sensitive</span>");		
		}
		else{
			$new_password = md5($new_password);
			$sql = "UPDATE auth_user_admin SET password='$new_password' WHERE username='".$_SESSION['username']."'";
			$results = mysql_query($sql);
			$smarty->assign('msg', "<span>Done, new settings saved successfully</span>");
		}
		}else{
			$smarty->assign('msg', "<span style='color:red'>Sorry, password does not match. Please re-enter old and new password</span>");
		}
	}
}

$sql = "SELECT * FROM store_settings WHERE store_id=".$store_id;
$results = mysql_query($sql);
while($row = mysql_fetch_assoc($results) )
{
	$store_settings[] = $row;
}

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

$sql = "SELECT * FROM currency ORDER BY currency_name";
$results = mysql_query($sql);
while($row = mysql_fetch_assoc($results) )
{
	$store_currency[] = $row;
}

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

$smarty->display('settings.tpl');
?>
Return current item: Simple PHP Shopping cart - asaancart