View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Add to Cart Javascript error

Thread began 1/03/2010 1:47 pm by georgina_barrett_187762 | Last modified 1/08/2010 6:44 pm by georgina_barrett_187762 | 1248 views | 5 replies

georgina_barrett_187762

That did allow me to add the 'add to cart' button. However when I upload the file and click the add to cart button it doesn't go to the shopping cart it redirects back to the same page.

This is the head code

<?php
//WA eCart Include
require_once("WA_eCart/eCart1_PHP.php");
?>
<?php
$eCart1->GetContent();
?>
<?php require_once('Connections/connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connect, $connect);
$query_depth = "SELECT DISTINCT tyres.`depth` FROM tyres ORDER BY tyres.`depth`";
$depth = mysql_query($query_depth, $connect) or die(mysql_error());
$row_depth = mysql_fetch_assoc($depth);
$totalRows_depth = mysql_num_rows($depth);

mysql_select_db($database_connect, $connect);
$query_size = "SELECT DISTINCT tyres.`size` FROM tyres ORDER BY tyres.`size`";
$size = mysql_query($query_size, $connect) or die(mysql_error());
$row_size = mysql_fetch_assoc($size);
$totalRows_size = mysql_num_rows($size);

mysql_select_db($database_connect, $connect);
$query_load = "SELECT DISTINCT tyres.load FROM tyres ORDER BY tyres.load";
$load = mysql_query($query_load, $connect) or die(mysql_error());
$row_load = mysql_fetch_assoc($load);
$totalRows_load = mysql_num_rows($load);

mysql_select_db($database_connect, $connect);
$query_speed = "SELECT DISTINCT tyres.speed FROM tyres ORDER BY tyres.speed";
$speed = mysql_query($query_speed, $connect) or die(mysql_error());
$row_speed = mysql_fetch_assoc($speed);
$totalRows_speed = mysql_num_rows($speed);

mysql_select_db($database_connect, $connect);
$query_width = "SELECT DISTINCT width FROM tyres ORDER BY width ASC";
$width = mysql_query($query_width, $connect) or die(mysql_error());
$row_width = mysql_fetch_assoc($width);
$totalRows_width = mysql_num_rows($width);

$colname_WADAtyres = "-1";
if (isset($_POST['S_width'])) {
$colname_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_width'] : addslashes($_POST['S_width']);
}
$colname5_WADAtyres = "-1";
if (isset($_POST['S_runflat'])) {
$colname5_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_runflat'] : addslashes($_POST['S_runflat']);
}
$colname3_WADAtyres = "-1";
if (isset($_POST['S_load'])) {
$colname3_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_load'] : addslashes($_POST['S_load']);
}
$colname4_WADAtyres = "-1";
if (isset($_POST['S_speed'])) {
$colname4_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_speed'] : addslashes($_POST['S_speed']);
}
$colname1_WADAtyres = "-1";
if (isset($_POST['S_depth'])) {
$colname1_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_depth'] : addslashes($_POST['S_depth']);
}
$colname2_WADAtyres = "-1";
if (isset($_POST['S_size'])) {
$colname2_WADAtyres = (get_magic_quotes_gpc()) ? $_POST['S_size'] : addslashes($_POST['S_size']);
}
mysql_select_db($database_connect, $connect);
$query_WADAtyres = sprintf("SELECT * FROM tyres WHERE tyres.sale >0 AND tyres.width = %s AND tyres.`depth` = %s AND tyres.`size`= %s AND tyres.speed LIKE %s AND tyres.load LIKE %s AND tyres.runflat >= %s", GetSQLValueString($colname_WADAtyres, "int"),GetSQLValueString($colname1_WADAtyres, "int"),GetSQLValueString($colname2_WADAtyres, "text"),GetSQLValueString("%" . $colname4_WADAtyres . "%", "text"),GetSQLValueString("%" . $colname3_WADAtyres . "%", "text"),GetSQLValueString($colname5_WADAtyres, "text"));
$WADAtyres = mysql_query($query_WADAtyres, $connect) or die(mysql_error());
$row_WADAtyres = mysql_fetch_assoc($WADAtyres);
$totalRows_WADAtyres = mysql_num_rows($WADAtyres);
?>
<?php
// WA eCart AddToCart
if (isset($_POST["eCart1_1_ATC"]) || isset($_POST["eCart1_1_ATC_x"])) {
$ATC_itemID = $_POST["eCart1_1_ID_Add"];
$ATC_AddIfIn = 0;
$ATC_RedirectAfter = "shoppingcart.php";
$ATC_RedirectIfIn = "";
if (isset($totalRows_WADAtyres) && $totalRows_WADAtyres > 0) {
$row_WADAtyres = WAEC_findRecordMySQL($WADAtyres, "tyresID", $ATC_itemID);
if ($row_WADAtyres) {
$ATC_itemName = "".$row_WADAtyres['name'] ."";// column binding
$ATC_itemDescription = "".$row_WADAtyres['width'] ."/".$row_WADAtyres['depth'] ." ".$row_WADAtyres['size'] ."";// column binding
$ATC_itemWeight = floatval("0");// column binding
$ATC_itemQuantity = "".$_POST["eCart1_1_Quantity_Add"] ."";// column binding
$ATC_itemPrice = floatval("".$row_WADAtyres['sale'] ."");// column binding
$ATC_itemMake = "".$row_WADAtyres['make'] ."";// column binding
mysql_data_seek($WADAtyres, 0);
$row_WADAtyres = mysql_fetch_assoc($WADAtyres);
}
}
$ATC_itemQuantity = floatval($ATC_itemQuantity);
if (is_numeric($ATC_itemQuantity) && $ATC_itemQuantity != 0) {
$eCart1->AddToCart($ATC_AddIfIn, $ATC_RedirectIfIn, $ATC_itemID, $ATC_itemName, $ATC_itemDescription, $ATC_itemWeight, $ATC_itemQuantity, $ATC_itemPrice, $ATC_itemMake);
if ($ATC_RedirectAfter != "" && $eCart1->redirStr == "") {
$eCart1->redirStr = $ATC_RedirectAfter;
}
if (isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != "") {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING'];
}
else {
$_SESSION['WAEC_ContinueRedirect'] = $_SERVER['PHP_SELF'];
}
}
}
?>
<?php
// WA eCart Redirect
if ($eCart1->redirStr != "") {
header("Location: ".$eCart1->redirStr);
}
?>



And the button code;

<div class="WADAResultCommerceButton"><form name="eCart1_1_ATC_<?php echo $row_WADAtyres["tyresID"]; ?>" method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?><?php echo (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] != "")?"?".$_SERVER["QUERY_STRING"]:""; ?>">
<input type="hidden" name="eCart1_1_ID_Add" value="<?php echo $row_WADAtyres["tyresID"]; ?>" >
<input type="text" name="eCart1_1_Quantity_Add" value="1" size="4" >
<input type="image" src="WA_eCart/Images/Nautica/Btn2_EN_addtocart.gif" border="0" value="Add to Cart" name="eCart1_1_ATC" alt="Add to cart">
</form></div>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...