Webmall problem

04/01/2015 06:22 Big_#1
i have got a problem with the webmall i keep getting content corupt error massage when i click buy on any items i think it has to do with the
$back_url is there another way to do this insted of $back_url
Code:
<?php
if (isset($_POST['buy'])) {
	$post_data = do_request($_POST, true);
	$back_url = str_replace('&', '&', base64_decode($_POST['back_url']));
	
	$left_empty_slots = 0;
	
	if ($_POST['js_enabled'] != 1)
		set_msg('You must have javascript enabled in your browser', 'error', $back_url, 'buy_msg_' . $post_data['id']);
	
	if (!$post_data)
		set_msg('Please fill all fields', 'error', $back_url, 'buy_msg_' . $post_data['id']);
		
	$query = mysql_query("SELECT * FROM donate_items WHERE id = '{$post_data['id']}'") or die();
	if (mysql_num_rows($query) <= 0)
		set_msg('Unexpected error!', 'error', $back_url, 'buy_msg_' . $post_data['id']);
		
	$item_data = mysql_fetch_array($query);
	
	if ($user_data['Point'] < $item_data['item_price'])
		set_msg("You do not have enough points", 'error', $back_url, 'buy_msg_' . $post_data['id']);
	
	if ($item_data['item_pack'] == 0) {
		if ($item_data['item_ali']) {
			$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
			$count_slots = mssql_num_rows($query);
			if ($config['max_slots'] > $count_slots)
				$left_empty_slots = $config['max_slots'] - $count_slots;
		
			if ($left_empty_slots >= $item_data['item_count']) {
				for($i=1;$i<=$item_data['item_count'];$i++) {
					$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
					$s = 0;
					$empty_slot = false;
					if (mssql_num_rows($query) > 0) {
						while ($row = mssql_fetch_array($query)) {
							$s++;
							
							if ($s <= $config['max_slots']) {
								$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}' AND slot = '{$s}'") or die();
								if (mssql_num_rows($query) <= 0) {
									$empty_slot = $s;
									break;
								}
							} else {
								$empty_slot = false;
								break;
							}
						}
						
						if ($empty_slot) {
							mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$item_data['item_id']}','1','" . date('Y-m-d H:i:s') . "')") or die();
						} else {
							set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
						}
					} else {
						$empty_slot = 1;
						mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$item_data['item_id']}','1','" . date('Y-m-d H:i:s') . "')") or die();
					}
				}
			} else {
				set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
			}
		} else {
			$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
			$s = 0;
			$empty_slot = false;
			if (mssql_num_rows($query) > 0) {
				while ($row = mssql_fetch_array($query)) {
					$s++;
					
					if ($s <= $config['max_slots']) {
						$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}' AND slot = '{$s}'") or die();
						if (mssql_num_rows($query) <= 0) {
							$empty_slot = $s;
							break;
						}
					} else {
						$empty_slot = false;
						break;
					}
				}

				if ($empty_slot) {
					mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$item_data['item_id']}','{$item_data['item_count']}','" . date('Y-m-d H:i:s') . "')") or die();
				} else {
					set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
				}
			} else {
				$empty_slot = 1;
				mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$item_data['item_id']}','{$item_data['item_count']}','" . date('Y-m-d H:i:s') . "')") or die();
			}
		}
		
		$new_points = $user_data['Point'] - $item_data['item_price'];
		mssql_query("UPDATE PS_UserData.dbo.Users_Master SET Point = '{$new_points}' WHERE UserUID = '{$user_data['UserUID']}'") or die();
		set_msg('Item purchased!', 'success', $back_url, 'buy_msg_' . $post_data['id']);
	} 
	// pack
	else {
		$ex_item_ali = explode(',', $item_data['item_ali']);
		$ex_item_name = explode(',', $item_data['item_name']);
		$ex_item_id = explode(',', $item_data['item_id']);
		$ex_item_count = explode(',', $item_data['item_count']);
		$count = count($ex_item_ali)-1;
		
		$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
		$count_slots = mssql_num_rows($query);
		if ($config['max_slots'] > $count_slots)
			$left_empty_slots = $config['max_slots'] - $count_slots;
		
		if ($left_empty_slots >= $count) {
			for ($e=0;$e<=$count;$e++) {
				if ($ex_item_ali[$e]) {
					for($i=1;$i<=$ex_item_count[$e];$i++) {
						$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
						$s = 0;
						$empty_slot = false;
						if (mssql_num_rows($query) > 0) {
							while ($row = mssql_fetch_array($query)) {
								$s++;

								if ($s <= $config['max_slots']) {
									$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}' AND slot = '{$s}'") or die();
									if (mssql_num_rows($query) <= 0) {
										$empty_slot = $s;
										break;
									}
								} else {
									$empty_slot = false;
									break;
								}
							}
							
							if ($empty_slot) {
								mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$ex_item_id[$e]}','1','" . date('Y-m-d H:i:s') . "')") or die();
							} else {
								set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
							}
						} else {
							$empty_slot = 1;
							mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$ex_item_id[$e]}','1','" . date('Y-m-d H:i:s') . "')") or die();
						}
					}
				} else {
					$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}'") or die();
					$s = 0;
					$empty_slot = false;
					if (mssql_num_rows($query) > 0) {
						while ($row = mssql_fetch_array($query)) {
							$s++;
							
							if ($s <= $config['max_slots']) {
								$query = mssql_query("SELECT UserUID FROM PS_GameData.dbo.UserStoredPointItems WHERE UserUID = '{$user_data['UserUID']}' AND slot = '{$s}'") or die();
								if (mssql_num_rows($query) <= 0) {
									$empty_slot = $s;
									break;
								}
							} else {
								$empty_slot = false;
								break;
							}
						}

						if ($empty_slot) {
							mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$ex_item_id[$e]}','{$ex_item_count[$e]}','" . date('Y-m-d H:i:s') . "')") or die();
						} else {
							set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
						}
					} else {
						$empty_slot = 1;
						mssql_query("INSERT INTO PS_GameData.dbo.UserStoredPointItems (UserUID, Slot, ItemID, ItemCount, BuyDate) VALUES ('{$user_data['UserUID']}','{$empty_slot}','{$ex_item_id[$e]}','{$ex_item_count[$e]}','" . date('Y-m-d H:i:s') . "')") or die();
					}
				}
			}
		} else{
			set_msg('No empty slots for items', 'error', $back_url, 'buy_msg_' . $post_data['id']);
		}
		
		$new_points = $user_data['Point'] - $item_data['item_price'];
		mssql_query("UPDATE PS_UserData.dbo.Users_Master SET Point = '{$new_points}' WHERE UserUID = '{$user_data['UserUID']}'") or die();
		set_msg('Items pack purchased!', 'success', $back_url, 'buy_msg_' . $post_data['id']);
	}
}
?>
04/01/2015 11:12 beetols#2
use a back url is the best way, else u can edit at begin a to static url like
Code:
$back_url = 'store.php';
but this will redirect only to first page.
btw fix your error shouldn't be hard if u show me the error message that u receive and the side where declare back_url .
04/01/2015 21:39 Big_#3
yeh i might have to make it 1 page so u add all the items to 1 page not septrate ones so i can $backurl = 'cat1'


wanna add my skype big__ben1 with two _ from new zealand in firefox the error is curupt content page shows in crome it just loads and loads and loads and dose nothing when u click buy on a item in IE u just get the stander error page
04/02/2015 01:13 sominus#4
The webmall needs several modifications to work properly. Also I recomend to use just the 'pack' section, even if you sell a single item.
And don't use the webmall to create items or packs, make your own page to do it (or create them directly on the DB), 'cause the webmall's edit page has some bugs.
04/02/2015 02:19 Big_#5
well i got it all working useing only 1 catagory and useing this $back_url = 'index.php?cat=1'; and did sumthign simaler in the admin part for adding and updateing items