Hi guys my script is working without error or warning messages but the site does not respond can any1 see the problem in the functions below?
Script 1
<?
include ('product_sc_fns.php');
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Checkout"
// if filled out
if($cart&&$name&&$first_add&&$city&&$zip&&$country)
{
// able to insert into database
if( insert_order($HTTP_POST_VARS)!=false )
{
$orderId=insert_order($HTTP_POST_VARS);
//display cart, not allowing changes and without pictures
display_cart($cart, false, 0);
display_shipping(calculate_shipping_cost());
//get credit card details
display_card_form($name,$orderId);
display_button("show_cart.php", "continue-shopping", "Continue Shopping"
}
else
{
echo "Could not store data, please try again.";
display_button("checkout.php", "back", "Back"
}
}
else
{
echo "You did not fill in all the fields, please try again.<hr>";
display_button("checkout.php", "back", "Back"
}
do_html_footer();
?>
Script 2
<?
include ('product_sc_fns.php');
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Checkout"
if($cart&&$card_type&&$card_number&&$card_month&&$card_year&&$card_name )
{
//display cart, not allowing changes and without pictures
display_cart($cart, false, 0);
display_shipping(calculate_shipping_cost());
if(process_card($HTTP_POST_VARS))
{
$toaddress="info@stewarthighland.com";
$subject="You have a new order";
$fromaddress="RJSneddon@blueyonder.co.uk";
$content="You have a new order click the link to view //empty shopping cart
session_destroy();
echo "Thankyou for shopping with us. Your order has been placed.";
display_button("index.php", "continue-shopping", "Continue Shopping"
}
else
{
echo "Could not process your card, please contact the card issuer or try again.";
display_button("purchase.php", "back", "Back"
}
}
else
{
echo "You did not fill in all the fields, please try again.<hr>";
display_button("purchase.php", "back", "Back"
}
do_html_footer();
?>
Script 3
function process_card($card_details)
{
$end=$card_month."/".$card_year;
$conn=db_connect();
$query="select threed from ccdet where ccno='$card_number'";
$result=mysql_query($query);
if($result >0)
{
return false;
}
else
{
$query="insert into ccdet values('','$card_number','$end','','Threed','$card_type','card_name')";
return true;
}
}
function insert_order($order_details)
{
global $total_price;
global $cart;
//extract order_details out as variables
extract($order_details);
//set shipping address same as address
if(!$ship_name&&!$ship_1st_add&&!$ship_2nd_add&&!$ship_city&&!$ship_state&&!$ship_zip&&!$ship_country)
{
$ship_name = $name;
$ship_1st_add = $first_add;
$ship_2nd_add = $second_add;
$ship_city = $city;
$ship_state = $state;
$ship_zip = $zip;
$ship_country = $country;
}
//insert customer address
$query = "select customerid from contact where name = '$name' and 1st_add = '$first_add' and 2nd_add = '$second_add' and town = '$city' and state = '$state' and zip = '$zip' and country = '$country'";
$result = @mysql_query($query);
if(mysql_num_rows($result)>0)
{
$customerid = mysql_result($result, 0, "customerid"
}
else
{
$query = "insert into contact values
('', '$name', '$first_add','$second_add','$city','$state','$zip','$tel','$fax','$country','$email')";
$result = mysql_query($query);
if (!$result)
return false;
}
$date = date("Y-m-d"
$query = "insert into orders values
('','$customerid','$total_price','$date','PARTIAL','$ship_name',
'$ship_1st_add','$ship_2nd_add','$ship_city','$ship_state','$ship_zip',
'$ship_country')";
$result = mysql_query($query);
if (!$result)
return false;
$query = "select orderid from orders where
customerid = $customerid and
amount > $total_price-.001 and
amount < $total_price+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$ship_name' and
ship_1st_add = '$ship_1st_add' and
ship_2nd_add = '$ship_2nd_add' and
ship_city = '$ship_city' and
ship_state = '$ship_state' and
ship_zip = '$ship_zip' and
ship_country = '$ship_country'";
$result = mysql_query($query);
if(mysql_num_rows($result)>0)
$orderid = mysql_result($result, 0, "orderid"
else
return false;
// insert each product
foreach($cart as $productId => $quantity)
{
$detail = get_product_details($productId);
$query = "delete from order_items where
orderid = '$orderid' and productId = '$productId'";
$result = mysql_query($query);
$query = "insert into order_items values
('$orderid', '$productId', ".$detail["price"].", $quantity)";
$result = mysql_query($query);
if(!$result)
return false;
}
return $orderid;
}
Script 1
<?
include ('product_sc_fns.php');
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Checkout"
// if filled out
if($cart&&$name&&$first_add&&$city&&$zip&&$country)
{
// able to insert into database
if( insert_order($HTTP_POST_VARS)!=false )
{
$orderId=insert_order($HTTP_POST_VARS);
//display cart, not allowing changes and without pictures
display_cart($cart, false, 0);
display_shipping(calculate_shipping_cost());
//get credit card details
display_card_form($name,$orderId);
display_button("show_cart.php", "continue-shopping", "Continue Shopping"
}
else
{
echo "Could not store data, please try again.";
display_button("checkout.php", "back", "Back"
}
}
else
{
echo "You did not fill in all the fields, please try again.<hr>";
display_button("checkout.php", "back", "Back"
}
do_html_footer();
?>
Script 2
<?
include ('product_sc_fns.php');
// The shopping cart needs sessions, so start one
session_start();
do_html_header("Checkout"
if($cart&&$card_type&&$card_number&&$card_month&&$card_year&&$card_name )
{
//display cart, not allowing changes and without pictures
display_cart($cart, false, 0);
display_shipping(calculate_shipping_cost());
if(process_card($HTTP_POST_VARS))
{
$toaddress="info@stewarthighland.com";
$subject="You have a new order";
$fromaddress="RJSneddon@blueyonder.co.uk";
$content="You have a new order click the link to view //empty shopping cart
session_destroy();
echo "Thankyou for shopping with us. Your order has been placed.";
display_button("index.php", "continue-shopping", "Continue Shopping"
}
else
{
echo "Could not process your card, please contact the card issuer or try again.";
display_button("purchase.php", "back", "Back"
}
}
else
{
echo "You did not fill in all the fields, please try again.<hr>";
display_button("purchase.php", "back", "Back"
}
do_html_footer();
?>
Script 3
function process_card($card_details)
{
$end=$card_month."/".$card_year;
$conn=db_connect();
$query="select threed from ccdet where ccno='$card_number'";
$result=mysql_query($query);
if($result >0)
{
return false;
}
else
{
$query="insert into ccdet values('','$card_number','$end','','Threed','$card_type','card_name')";
return true;
}
}
function insert_order($order_details)
{
global $total_price;
global $cart;
//extract order_details out as variables
extract($order_details);
//set shipping address same as address
if(!$ship_name&&!$ship_1st_add&&!$ship_2nd_add&&!$ship_city&&!$ship_state&&!$ship_zip&&!$ship_country)
{
$ship_name = $name;
$ship_1st_add = $first_add;
$ship_2nd_add = $second_add;
$ship_city = $city;
$ship_state = $state;
$ship_zip = $zip;
$ship_country = $country;
}
//insert customer address
$query = "select customerid from contact where name = '$name' and 1st_add = '$first_add' and 2nd_add = '$second_add' and town = '$city' and state = '$state' and zip = '$zip' and country = '$country'";
$result = @mysql_query($query);
if(mysql_num_rows($result)>0)
{
$customerid = mysql_result($result, 0, "customerid"
}
else
{
$query = "insert into contact values
('', '$name', '$first_add','$second_add','$city','$state','$zip','$tel','$fax','$country','$email')";
$result = mysql_query($query);
if (!$result)
return false;
}
$date = date("Y-m-d"
$query = "insert into orders values
('','$customerid','$total_price','$date','PARTIAL','$ship_name',
'$ship_1st_add','$ship_2nd_add','$ship_city','$ship_state','$ship_zip',
'$ship_country')";
$result = mysql_query($query);
if (!$result)
return false;
$query = "select orderid from orders where
customerid = $customerid and
amount > $total_price-.001 and
amount < $total_price+.001 and
date = '$date' and
order_status = 'PARTIAL' and
ship_name = '$ship_name' and
ship_1st_add = '$ship_1st_add' and
ship_2nd_add = '$ship_2nd_add' and
ship_city = '$ship_city' and
ship_state = '$ship_state' and
ship_zip = '$ship_zip' and
ship_country = '$ship_country'";
$result = mysql_query($query);
if(mysql_num_rows($result)>0)
$orderid = mysql_result($result, 0, "orderid"
else
return false;
// insert each product
foreach($cart as $productId => $quantity)
{
$detail = get_product_details($productId);
$query = "delete from order_items where
orderid = '$orderid' and productId = '$productId'";
$result = mysql_query($query);
$query = "insert into order_items values
('$orderid', '$productId', ".$detail["price"].", $quantity)";
$result = mysql_query($query);
if(!$result)
return false;
}
return $orderid;
}