Hello,
Actually the code I had posted earlier was a simplified version of shipping.php. Shipping. php displays shipping method (a drop down select box), payment (a drop down select box) displaying customer's credit card, shipping and handling link and the continue button. Once the customer clicks the continue button, it should go to the confirm page (confirm.php). The conditions are slightly different for new customers. However, nothing seems to happen when I click the continue button. I think there is a big BUG that I'm not able to find.
shipping.php has been validated with the w3 validator. There is only one error that I'm not able to fix:
Line 179, Column 9: end tag for "select" which is not finished
</select>
I have highlighted the </select> in red.
I am also highlighting the continue button in orange.
the following is shipping.php
<?php ob_start();
@session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Shipping and Payment</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script language="JavaScript" src="shipping_check.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
<!--
function mySubmitFunction_oldcust(which,choice,cr_card_exist_flag,ship_pymt_changed_flag)
{document.write(choice,cr_card_exist_flag,ship_pymt_changed_flag);
if (ship_pymt_changed_flag=='false')
if (choice==2)
if (cr_card_exist_flag=='false') //FOR OLD CUSTOMERS WITH NO CREDIT_CARD RECORD
if (validate_form(which)==true)
{which.action="confirm.php";
which.submit();
}//cr_card_exist_flag=='false'
else //FOR OLD CUSTOMERS WITH CREDIT_CARD RECORD
{//document.write("hello");
which.action="confirm.php";
which.submit();}
else //TO UPDATE SHIP_PYMT IF USER CLICKED <change payment> or <change shipping> links
{which.action="confirm.php";
which.submit();
}
}
function mySubmitFunction_newcust(which,choice,cr_card_exist_flag,ship_pymt_changed_flag)
{document.write("hello");
if (ship_pymt_changed_flag=='false') //TO UPDATE SHIP_PYMT IF USER CLICKED <change payment> or <change shipping> links
if (validate_form(which)==true)
if (choice==0) //BILLING ADDR IS NOT THE SAME AS SHIPPING ADDR
{which.action="shipping_addr.php";
which.submit();
}
else
{which.action="confirm.php";
which.submit();
}
else
if (validate_form(which)==true);
{which.action="confirm.php";
which.submit();}
}
//-->
</script>
</head>
<body>
<div id="container">
<div>
<iframe src ="/page_header.html" width="100%" height="159" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" >
<p>Your browser does not support iframes.</p>
</iframe>
</div>
<div id="body">
<?php
include("db.php");
include("cr_card_disp.php");
include("ship_pymt_maint.php");
// Get a connection to the database
$cxn = @ConnectToDb($server, $user, $pass, $database);
$_SESSION['ship_pymt_changed_flag']="false";
if (isset($_POST['save']))
$_SESSION['add_pymt_flag']=1;
if (isset($_POST['cancel']))
$_SESSION['add_pymt_flag']=0;
if (isset($_POST['continue']))
{if ($_SESSION['custExisting']=="No")//NEW CUSTOMER
//************************************************************************************************
/*if a cust has entered data into form in incorrect format, the form is validated and redisplayed.
At this point, billing_addr has already been inserted into billing_addr table
(when Continue was press the first time).So the following is to avoid duplicate entry in
billing_addr table.*/
//************************************************************************************************
if (isset($_SESSION['cust_id']))
{$sql = "select * from billing_addr where cust_id=".$_SESSION['cust_id']."";
$result=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result)==0)
{ echo ("calling assign_billing_addr1");
assign_billing_addr();
}
}
else
{
echo ("calling assign_billing_addr2");
assign_billing_addr();
}
//*****if customer clicks Add Credit Card Button****
if (isset($_SESSION['add_pymt_flag']))
{if ($_SESSION['add_pymt_flag']==1)
{assign_new_cr_card();
add_cr_card();
$_SESSION['add_pymt_flag']=FALSE; //UNREGISTER SESSION VARIABLE
}
if ($_SESSION['add_pymt_flag']==0)
{$_SESSION['add_pymt_flag']=FALSE;
}
}
//*************************************************************
show_ship_pymt();
}//end NEW CUSTOMER
else //OLD CUSTOMER
if (isset($_GET['upd_ship_pymt'])) //if user clicks "Change Shipping Address" button on confirm.php
{$_SESSION['ship_pymt_changed_flag']="true";
show_ship_pymt();
}
else
show_ship_pymt();
//end isset($_POST['continue'])
function assign_billing_addr()
{ //echo "isShippingAddress: ".$_POST['isShippingAddress'];
$_SESSION['b_name']=$_POST['b_name'];
$_SESSION['b_address1']=$_POST['b_address1'];
$_SESSION['b_address2']=$_POST['b_address2'];
$_SESSION['b_city']=$_POST['b_city'];
$_SESSION['b_state']=$_POST['b_state'];
$_SESSION['b_zip']=$_POST['b_zip'];
$_SESSION['b_country']=$_POST['b_country'];
$_SESSION['b_phone']=ereg_replace('[^0-9]', '', $_POST['b_phone']);
$_SESSION['isShippingAddress']=$_POST['isShippingAddress'];
add_billing_addr(); //in ship_pymt_maint.php
}
function assign_new_cr_card()
{
$_SESSION['cr_card']=$_POST['cr_card'];
$_SESSION['complete_cr_no']=$_POST['cr_no'];
$_SESSION['cr_no']=substr($_POST['cr_no'],-5);
$_SESSION['exp_mth']=$_POST['exp_mth'];
$_SESSION['exp_yr']=$_POST['exp_yr'];
}
function show_ship_pymt()
{
$sql = "Select shipping_method from shipping_rate";
$result = mysql_query($sql) or die(mysql_error());
disp_error(); //disp error msg for dup cr_card entry & disp error msg for shipping_mtd
echo '<div id="error_box" name="error_box" class="messageNo"></div>';
echo '<br><br>';
?>
<form action="confirm.php" method="post">
<div style="position:relative; margin:40px;">
<div class="form_label2">Shipping Method: </div>
<div class="form_element" style="left:15%;">
<select name="shipping method">
<?php
while ($row = mysql_fetch_array($result))
{ echo "<option value='".$row["shipping_method"]."'>".$row["shipping_method"]."</option>";
}
?>
[COLOR="Red"]</select>[/COLOR]
</div>
<!--to display a small window containing shipping_details.php on top of shipping.php page-->
<div class="form_element" style="left:40%;">See details about <a href='#' onclick="window.open('shipping_details.php','win1','width=600,height=300')">shipping and handling charges</a></div>
<?php
if ($_SESSION['custExisting']=="Yes") //OLD CUSTOMER
{
$sql="select * from credit_card where cust_id=".$_SESSION['cust_id']."";
$result=mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result)>0) //IF OLD CUST HAS RECORD IN SHIP_PYMT TABLE
{
$_SESSION['cr_card_exist_flag']="true";
cr_card_disp1();
}
else
{$_SESSION['cr_card_exist_flag']="false";
cr_card_disp2();
}
$choice=2;
//if (isset($_SESSION['isShippingAddress']))
//{echo "isShippingAddress: ". $_SESSION['isShippingAddress'];}
echo "<div style='position:absolute; top:27.5%; right:50%; height:10em; margin-top:-5em;'>";
//echo "<input type=button name='submitter' value='Continue' onclick=mySubmitFunction_oldcust(this.form,2,'true','false')>";
[COLOR="DarkOrange"] echo "<input type='button' name='submitter' value='Continue' onclick='mySubmitFunction_oldcust(this.form, ".$choice.",'".$_SESSION['cr_card_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')'>";
echo "</div>";[/COLOR]
}
else //NEW CUSTOMER
{$_SESSION['cr_card_exist_flag']="false";
cr_card_disp2();
echo "<div style='position:absolute; top:27.5%; right:50%; height:10em; margin-top:-5em;'>
<input type='button' name='submitter' value='Continue' onclick='mySubmitFunction_newcust(this.form,".$_SESSION['isShippingAddress'].",'".$_SESSION['cr_card_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')'></div>";
}
?>
</div>
</form>
<?php
}//END SHOW_SHIP_PYMT
?>
</div>
<div id="footer" style="position:absolute; ">
<iframe src ="/page_footer.html" height="88" width="100%" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" >
<p>Your browser does not support iframes.</p>
</iframe>
</div>
</div>
</body>
</html>
thanks a lot for all your help!