if ($mode == "add" && strpos($_SERVER['HTTP_REFERER'], "cart.php")>0 )
if ($mode == "add" && (strpos($_SERVER['HTTP_REFERER'], "cart.php") == false))