In my previous post, I forgot to highlight where the error was occuring. The code in red displays the continue button that passes values to the javascript mySubmitFunction. When I run this code and click the continue button nothing happens. I'm getting "error on page" at the bottom of the browser. What could be wrong? Please help!
<?php ob_start();
session_start();
header("Cache-control: private"); //IE 6 Fix
?>
<html><head>
<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(which,choice,custExisting,cr_card_exist_flag,ship_pymt_changed_flag)
{document.write("hello");
if (ship_pymt_changed_flag=='true') //TO UPDATE SHIP_PYMT IF USER CLICKED <change payment> or <change shipping> links
if (custExisting=='No')//NEW CUST
{if (validate_form(which)==true);
{which.action="confirm.php";
which.submit();}
}
else //OLD CUST
{which.action="confirm.php";
which.submit();}
}
else
if (custExisting=='No')//NEW CUST
if (validate_form(which)==true)
if (choice==0) //BILLING ADDR IS NOT THE SAME AS SHIPPING ADDR
{which.action="shipping_addr.php";}
else
{which.action="confirm.php";}
which.submit();
else //OLD CUST
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();}
else
{error_box.innerHTML="Error in processing your details!";
error_box.className="messageYes";}
else //FOR OLD CUSTOMERS WITH CREDIT_CARD RECORD
{document.write("hello");
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" vspace="0" hspace="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)
{
assign_billing_addr();}
}
else
assign_billing_addr();
}
//**if customer clicks Add Credit Card Button
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;}
//************************************************************
//$_SESSION['ship_pymt_changed_flag']="false";
show_ship_pymt();
}
else
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();
function assign_billing_addr()
{
$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']=$POST['b_phone'];
$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());
//TEMP COMMENTED ------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
//if (isset($SESSION['shipping_method']) || isset($POST['shipping_method']))
while ($row = mysql_fetch_array($result))
{ echo "<option>".$row["shipping_method"];
/* {if ($SESSION['shipping_method'] == $row["shipping_method"] || $POST['shipping_method'] == $row["shipping_method"])
echo "<option selected>".$row["shipping_method"];
else
echo "<option>".$row["shipping_method"];
}*/
}
?>
</select></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
//$SESSION['ship_pymt_changed_flag']=true; ----22/6/2010
/
if ($SESSION['custExisting']=="Yes") //OLD CUSTOMER
{$sql="select from ship_pymt 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['ship_pymt_exist_flag']="true";
cr_card_disp1(); }
else
{$_SESSION['ship_pymt_exist_flag']="false";
cr_card_disp2();}
echo "<input type=button name='submitter' value='Continue' onclick=\"mySubmitFunction(this.form,2,'".$_SESSION['custExisting']."','".$_SESSION['ship_pymt_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')\">";
}
else //NEW CUSTOMER
{$SESSION['ship_pymt_exist_flag']="false";
cr_card_disp2();
echo " <input type=button name='submitter' value='Continue' onclick=\"mySubmitFunction(this.form,".$SESSION['isShippingAddress'].",'".$SESSION['custExisting']."','".$SESSION['ship_pymt_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')\">";
}
*/
//if (isset($SESSION['ship_pymt_changed_flag'])) -----22/6/2010
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:70px; right:70%; vertical-align:baseline;'>
[COLOR="Red"] <input type=button name='submitter' value='Continue' onclick=\"mySubmitFunction(this.form, ".$choice.",'".$_SESSION['custExisting']."','".$_SESSION['cr_card_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')\"></div>"; [/COLOR]
}
else //NEW CUSTOMER
{$SESSION['cr_card_exist_flag']="false";
cr_card_disp2();
echo "<div style='position:absolute; top:70px; right:70%; vertical-align:baseline;'>
<input type=button name='submitter' value='Continue' onclick=\"mySubmitFunction(this.form,".$SESSION['isShippingAddress'].",'".$SESSION['custExisting']."','".$SESSION['cr_card_exist_flag']."','".$_SESSION['ship_pymt_changed_flag']."')\"></div>";
}
?>
</div>
</form>
<?php
}//END SHOW_SHIP_PYMT
?>
<div id="footer" style="position:absolute; bottom:-300px;">
<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>
thank you.
Varai