我上个月试图让这个ColdFusion问题起作用...我有5个cfm文件。以下是我遇到的以下问题: ShoppingCart.cfm:表格是级联而不是保持相同的格式。 revieworder.cfm:来自customerinfo.cfm页面的customerinfo没有显示出来。 OrderConfirmation.cfm:通过电子邮件向客户发送发票的副本是不行的...坦率地说,整个事情都没有工作,我觉得它与会话有关:application.cfm文件。如果有人可以帮我指导这些,我会非常感谢!!
的Application.cfc
<cfcomponent>
<cfset this.name = "mmd24shoppingcart">
<cfset this.datasource = "mmd24_shoppingcart">
<cfset this.sessionmanagement="Yes">
<cfset this.sessiontimeout="#createtimespan(0,0,45,0)#">
<cfset This.applicationtimeout="#createtimespan(5,0,0,0)#">
<cffunction name = "onApplicationStart">
<cfscript>
Application.availableResources=0;
Application.counter1=1;
Application.sessions=0;
</cfscript>
</cffunction>
<cffunction name="onSessionStart">
<cfscript>
Session.started = now();
Session.shoppingCart = Structnew();
Session.shoppingCart.items =0;
</cfscript>
</cffunction>
</cfcomponent>
&#13;
shoppingcart.cfm
<!doctype html>
<htmllang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<head>
<cfparam name="url.productid" default="">
<cfparam name="url.qty" default="">
</head>
<title>shoppingcart</title>
<body>
<div class="container">
<h3><center>Shopping Cart</center></h3>
<cfquery name = "getlist" datasource="mmd24_shoppingcart">
SELECT *
FROM Products
WHERE Products.productID = <cfqueryparam
cfsqltype="cf_sql_integer" value="#url.productid#">
</cfquery>
<cflock scope="session" timeout="10">
<cfset addNew = true>
<cfif not isDefined("session.cart")>
<cfset session.cart = arrayNew(1)>
<cfelse>
<cfloop index="i" from="1"
to="#arrayLen(session.cart)#">
<cfif URL.productid is session.cart[i].productId>
<cfset session.cart[i].productQty =
session.cart[i].productQty + 1>
<cfset addNew = false>
</cfif>
</cfloop>
</cfif>
<cfif addNew is true>
<cfset newItem=StructNew()>
<cfset newItem.productId = URL.productid>
<cfset newItem.productName = getlist.ProductName>
<cfset newItem.productPrice = getlist.ProductPrice>
<cfset newItem.productDescription =
getlist.ProductDescription>
<cfset newItem.productQty = URL.qty>
<cfset newItem.productPhoto = getlist.ProductPhoto>
<cfset ArrayAppend(session.cart, newItem)>
</cfif>
<cfset TotalOrderAmount = 0>
<cfset TotalItemAmount = 0>
<cfset TotalTax = 0>
<cfset counterhi = 0>
</cflock>
<cfoutput query ="getlist">
<cflock scope="session" type="readonly" timeout="10">
<cfloop index="i" from="1" to="#arrayLen(session.cart)#">
<table class = "table table-bordered">
<thead>
<tr>
<th>Product Photo</th>
<th>Product Name</th>
<th>Product Description</th>
<th>Quantity Ordered</th>
<th>Product Price</th>
</th>
</thead>
<tbody>
<tr>
<td><img src="#session.cart[i].ProductPhoto#"></td>
<td>#session.cart[i].ProductName#</td>
<td>#session.cart[i].ProductDescription#</td>
<td>#session.cart[i].ProductQty#</td>
<td>#DollarFormat(session.cart[i].ProductPrice)#</td>
</tr>
</tbody>
<table class = "table">
<cfset Itemtotal = #getlist.productprice# *
#session.cart[i].ProductQty#>
<cfset OrderTotal = #Itemtotal#>
<cfset Tax = #OrderTotal# * "0.08">
<cfset TotalOrderAmount = #OrderTotal# + #Tax# + #TotalOrderAmount#>
<cfset TotalItemAmount = #Itemtotal# + #TotalItemAmount#>
<cfset TotalTax = #Tax# + #TotalTax#>
<tr>
<td class="col-lg-9 text-right">Subtotal</td>
<td class="text - left">#DollarFormat(itemTotal)#</td>
</tr>
<tr>
<td class="col-lg-9 text-right">Tax(8%)</td>
<td>#DollarFormat(Tax)#</td>
</tr>
<tr>
<td class="col-lg-9 text-right">Order Total</td>
<td>#DollarFormat(TotalOrderAmount)#
<br>
<br>
</cfloop>
</cflock>
</cfoutput>
<a input type="submit" name="submit" href="customerinfo.cfm"
class="btn btn-primary" role="button">Proceed to Checkout</a>
<br>
</br>
<a input type="submit" name="submit" href="productlist.cfm"
class="btn btn-primary" role="button">Continue Shopping</a>
</td>
</tr>
</tbody>
</div>
<script src="js/bootstrap.js"></script>
</body>
</html>
&#13;
customerinfo.cfm
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Customer Info</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Html5TemplatesDreamweaver.com">
<link href="scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="scripts/bootstrap/css/bootstrap-responsive.min.css"
rel="stylesheet">
<script src="js/jquery.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
</head>
<body id="pageBody">
</script>
<table border="3" style="background-color:#FFFFFF;border-
collapse:collapse;
border:3px solid #0033FF;color:#000000;">
<tr>
<td>
<div id="divHeaderLine1">Billing Address</div>
<br>
<label for="bFirstName"><font color="red">*</font>First Name</label>
<input type="text" size="20" required=""
name="bFirstName" id="bFirstName">
<br>
<label for="bLastName"><font color="red">*</font>Last Name</label>
<input type="text" size="20" required=""
name="bLastName">
<br>
<label for="bAddress"><font color="red">*</font>Address</label>
<input type="text" size="20" required="" name="bAddress">
<br>
<label for="bCity"><font color="red">*</font>City</label>
<input type="text" size="20" required="" name="bCity">
<br>
<label for="bState"><font color="red">*</font>State</label>
<select name="bState" size=”4”>
<option value="" selected></option>
<option value="GA">Georgia</option>
<option value="FL">Florida</option>
<option value="AL">Alabama</option>
<option value="TX">Texas</option>
<option value="MS">Mississippi</option>
<option value="LA">Louisiana</option>
</select>
<br>
<label for="bZip"><font color="red">*</font>Zip Code</label>
<input type="text" size="20" required="" name="bZip">
<br>
<label for"bEmail"><font color="red">*</font>Email Address</label>
<input type="text" size="20" name="bEmail">
</td>
<td>
<div id="divHeaderLine1">Shipping Address</div>
<br>
</br>
<input type="checkbox" name="billingtoo"
onclick="FillBilling(this.form)">Same as billing
<br>
<br>
<label for="sFirstName"><font color="red">*</font>First Name</label>
<input type="text" size="20" name="sFirstName">
<label for="sLastName"><font color="red">*</font>Last Name</label>
<input type="text" size="20" name="sLastName">
<br>
<label for="sAddress"><font color="red">*</font>Address</label>
<input type="text" size="20" name="sAddress">
<br>
<label for="sCity"><font color="red">*</font>City</label>
<input type="text" size="20" name="sCity">
<br>
<label for="sState"><font color="red">*</font>State</label>
<select name="sState" size=”4”>
<option value="" selected></option>
<option value="GA">Georgia</option>
<option value="FL">Florida</option>
<option value="AL">Alabama</option>
<option value="TX">Texas</option>
<option value="MS">Mississippi</option>
<option value="LA">Louisiana</option>
</select>
<br>
<label for="sZip"><font color="red">*</font>Zip Code</label>
<input type="text" size="20" name="sZip">
<br>
<label for="sEmail"><font color="red">*</font>Email Address</label>
<input type="text" size="20" name="sEmail">
<br/>
</td>
</tr>
<tr>
<td>
<div id="divHeaderLine1">Shipping Method</div>
<br>
</br>
<input class="validate[required] checkbox" type="checkbox"
name="Shipping" value="OverNight"> Over Night <br/>
<input class="validate[required] checkbox" type="checkbox"
name="Shipping" value="OneDay"> One Day <br/>
<input class="validate[required] checkbox" type="checkbox"
name="Shipping" value="TwoDay" checked> Two Day <br/>
<br>
</td>
<td>
<div id="divHeaderLine1">Payment Details</div>
<br>
<br>
<celect class="cc-ddl-type">
<input class="validate[required] radio" type="radio"
name="CC" value="Visa" checked> Visa <br/>
<input class="validate[required] radio" type="radio"
name="CC" value="Master"> Master <br/>
<input class="validate[required] radio" type="radio"
name="CC" value="Discover"> Discover <br/>
<br><label><font color="red">*</font> Card Number </label>
<input value="" class="ccNumber" type="text" required="">
<br>
<label>Expires on:</label>
<select name="ccMonth" class="validate[required]">
<option value="January">January</option>
<option
value="February">February</option>
<option
value="March">March</option>
<option
value="April">April</option>
<option value="May">May</option>
<option
value="June">June</option>
<option
value="July">July</option>
<option
value="August">August</option>
<option
value="September">September</option>
<option
value="October">October</option>
<option
value="November">November</option>
<option
value="December">December</option>
</select>
<br/>
<select name="ccYear"
class="validate[required]">
<option
value="2011">2016</option>
<option
value="2012">2017</option>
<option
value="2013">2018</option>
<option
value="2014">2019</option>
<option
value="2015">2020</option>
</select>
</td>
</tr>
<br/>
<br>
<tr>
<td colspan="2" style="text-align: center; vertical-align: middle;">
<a input type="submit" href="revieworder.cfm" class="btn btn-primary"
role="button">Review Order</a>
</td>
</tr>
</table>
</form>
<script src="scripts/jquery.min.js" type="text/javascript"></script>
<script src="scripts/bootstrap/js/bootstrap.min.js"
type="text/javascript"></script>
<script src="scripts/default.js" type="text/javascript"></script>
</body>
</html>
&#13;
revieworder.cfm
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>revieworder</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link href="scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="scripts/bootstrap/css/bootstrap-responsive.min.css"
rel="stylesheet">
<cfparam name="form.bFirstName" default="">
<cfparam name="form.bLastName" default="">
<cfparam name="form.bAddress" default="">
<cfparam name="form.bCity" default="">
<cfparam name="form.bState" default="">
<cfparam name="form.bZip" default="">
<cfparam name="form.bEmail" default="">
<cfparam name="form.sFirstName" default="">
<cfparam name="form.sLastName" default="">
<cfparam name="form.sAddress" default="">
<cfparam name="form.sCity" default="">
<cfparam name="form.sState" default="">
<cfparam name="form.sZip" default="">
<cfparam name="form.sEmail" default="">
<cfparam name="form.ccNumber" default="">
<cfparam name="form.ccMonth" default="">
<cfparam name="form.ccYear" default="">
<cfparam name="form.shipping" default="">
<cfparam name="form.CC" default="">
<cfset TotalOrderAmount = 0>
<cfset TotalItemAmount = 0>
<cfset TotalTax = 0>
<cfset ShippingTotal = 0>
</head>
<body id="pageBody">
<form action="OrderConfirmation.cfm" method="post">
<table border="1" width="100%" align="center">
<thead>
<tr>
<cfoutput>
<td width="20%">
Product Photo</td>
<td width="20%">
Product Name</td>
<td width="20%">
UnitPrice</td>
<td width="20%">
Quantity Ordered</td>
<td width="20%">
Total Cost</td>
</td>
</tr>
<tr>
<cflock scope="session" type="readonly" timeout="5">
<cfparam name="session.cart" default="#ArrayNew(1)#">
<cfset cart = ArrayLen(session.cart)>
<cfset total = 0>
<cfloop index="i" from="1" to="#cart#">
<td width="20%">
<cfset Itemtotal = #session.cart[i].ProductPrice# *
#session.cart[i].ProductQty#>
<cfset OrderTotal = #session.cart[i].ProductPrice#>
<cfset Tax = #OrderTotal# * "0.08">
<cfset TotalOrderAmount = #OrderTotal# + #Tax# +
#TotalItemAmount#>
<cfset TotalItemAmount = #Itemtotal# >
<cfset TotalTax = #Tax# + #TotalTax#>
<cfif #Shipping# is "Ground">
<cfset ShippingTotal = .01 * #TotalOrderAmount#>
</cfif>
<cfif #Shipping# is "Air">
<cfset ShippingTotal = .02 * #TotalOrderAmount#>
</cfif>
<cfif #Shipping# is "Overnight">
<cfset ShippingTotal = .03 * #TotalOrderAmount#>
</cfif>
<tr>
<td colspan="1"><b>
<img src="#session.cart[i].ProductPhoto#"></b></td>
<td colspan="1"><b>
#session.cart[i].ProductName#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductPrice#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductQty#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductPrice#</b></td>
</tr>
</cfloop>
</cflock>
</tr>
<td colspan="4"><b>
Order Amount</b></td>
<td colspan="1"><b>
<center>#DollarFormat(TotalItemAmount)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Tax</b></td>
<td colspan="1"><b>
<center>#DollarFormat(TotalTax)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Shipping Cost </b></td>
<td colspan="1"><b>
<center>#DollarFormat(ShippingTotal)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Order Total</b></td>
<td colspan="1"><b>
<cfset TotalOrderAmount = + #TotalOrderAmount#>
<center>#DollarFormat(TotalOrderAmount)#</center></td>
</tr>
</cfoutput>
</thead>
</table>
<div id="divHeaderText" class="page-content">
<div id="divHeaderLine1">Your Address and Payment Details</div>
</br>
<table border="1" width="75%" align="center">
<tr>
<cfoutput>
<td><b>Billing Address:</td></b>
<td width="80%">
#Form.bFirstName# #Form.bLastName#<br>
#Form.bAddress# <br>
#Form.bCity#, #Form.bState# #Form.bZip#<br>
<strong>Email: </strong>#Form.bEmail#<br></td>
</tr>
<tr>
<td><b>Shipping Address:</b></td>
<td>
#form.sFirstName# #form.sLastName# <br>
#form.sAddress#<br>
#form.sCity#, #form.sState# #form.sZip#<br>
<b>Email: </b>#form.sEmail#<br>
</td>
</tr>
<tr>
<td><b>Payment Type:</td> </b><br><td>
#form.CC# Credit Card Number: #REReplace(form.ccNumber,"
[0-9](?=.*.{4})", "*", "all")# <br>
<tr>
<td>
<b>Exp Date: </b></td><td>#form.ccMonth# /#form.ccYear#
</td>
</td>
</tr>
</cfoutput>
</thead>
</table>
<br><br><br><br>
<input type="hidden" name="Email" value="<cfoutput>#form.bEmail#
</cfoutput>"/>
<input type="hidden" name="ShippingA" value="<cfoutput>#ShippingTotal#
</cfoutput>"/>
<input type="hidden" name="OrderA" value="<cfoutput>#TotalOrderAmount#
</cfoutput>"/>
<input type="hidden" name="ItemA" value="<cfoutput>#TotalItemAmount#
</cfoutput>"/>
<input type="hidden" name="TaxA" value="<cfoutput>#TotalTax#
</cfoutput>"/>
<input type="hidden" name="Address" value="<cfoutput>#form.bAddress#
</cfoutput>"/>
<input type="hidden" name="Shipping" value="<cfoutput>#form.Shipping#
</cfoutput>"/>
<a input type="submit" value="submit" href="OrderConfirmation.cfm"
class="btn btn-primary" role="button">Confirm Order</a>
</form>
</body>
</html>
&#13;
订单Confirmation.cfm(这是一切都搞砸了)
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Order Confirmation</title>
<cfparam name="form.email" default="VOID">
<cfparam name="form.Shipping" default="">
<cfparam name="form.address" default="">
<cfparam name="form.ShippingA" default="0">
<cfparam name="form.OrderA" default="0">
<cfparam name="form.ItemA" default="0">
<cfparam name="form.TaxA" default="0">
Email Confirmation
<cfmail from="mmd24@students.uwf.edu" to="#form.email#" subject="Your
Order Confirmation" type="html">
<html>
<head></head>
<body>
<cfset r = randomize(7, "SHA1PRNG")>
<cfset Int = 10000 />
<cfset Int2 = 80000 />
<cfoutput>
Thank you for your Order #session.customerform.BfirstName#
#session.customerform.BlastName#</br>
Your order numer is #randRange(Int, Int2, "SHA1PRNG")# </br>
<cfif #session.customerform.Shipping# is "OverNight">
Your order will arive in 12 Hours since you opted
for Over Night shipping
</cfif>
<cfif #session.customerform.Shipping# is "OneDay">
Your order will arive in 1 day since you opted for One
Day shipping
</cfif>
<cfif #session.customerform.Shipping# is "TwoDay">
Your order will arive in 2 days since you opted for
Two Day shipping
</cfif></br>
Your order will be shipped to the following address:
#session.customerform.address#
<table border="1" width="100%" align="center">
<thead>
<tr>
<th colspan="5">
Your Order Details
</th>
</tr>
<tr>
<cfoutput>
<td width="20%">
Product Photo</td>
<td width="20%">
Product Name</td>
<td width="20%">
UnitPrice</td>
<td width="20%">
Quantity Ordered</td>
<td width="20%">
Total Cost</td>
</td>
</tr>
<tr>
<cflock scope="session" type="readonly" timeout="5">
<cfparam name="session.cart" default="#ArrayNew(1)#">
<cfset cart = ArrayLen(session.cart)>
<cfset total = 0>
<cfloop index="i" from="1" to="#cartSize#">
<td width="20%">
<tr>
<td colspan="1"><b>
<img src="#session.cart[i].ProductPhoto#"></b></td>
<td colspan="1"><b>
#session.cart[i].ProductName#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductPrice#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductQTY#</b></td>
<td colspan="1"><b>
#session.cart[i].ProductPrice#</b></td>
</tr>
</cfloop>
</cflock>
</tr>
<td colspan="4"><b>
Order Amount</b></td>
<td colspan="1"><b>
<center>#DollarFormat(form.ItemA)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Tax</b></td>
<td colspan="1"><b>
<center>#DollarFormat(form.TaxA)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Shipping Cost (Shipping Method: #session.customerform.Shipping#)
</b></td>
<td colspan="1"><b>
<center>#DollarFormat(form.ShippingA)#</center></td>
</tr>
<tr>
<td colspan="4"><b>
Order Total</b></td>
<td colspan="1"><b>
<center>#DollarFormat(form.OrderA)#</center></td>
</tr>
</cfoutput>
</thead>
</table>
</cfoutput>
</body>
</html>
</cfmail>
</head>
<cflock scope="session" timeout="10">
<cfset session.customerform = StructNew()>
<cfset session.customerform.bFirstName = form.bFirstName>
<cfset session.customerform.bLastName = form.bFastName>
<cfset session.customerform.bAddress = form.bAddress>
<cfset session.customerform.bCity = form.bCity>
<cfset session.customerform.bCtate = Form.bState>
<cfset session.customerform.bZipCode = Form.bZipCode>
<cfset session.customerform.bEmail = Form.bEmail>
<cfset session.customerform.sFirstName = Form.sFirstName>
<cfset session.customerform.sLastName = Form.sLastName>
<cfset session.customerform.sAddress = Form.sAddress>
<cfset session.customerform.sCity = Form.sCity>
<cfset session.customerform.sState = Form.sState>
<cfset session.customerform.sZipCode = Form.sZipCode>
<cfset session.customerform.sEmail = Form.sEmail>
<cfset session.customerform.CC = Form.CC>
<cfset session.customerform.ccMonth = Form.ccMonth>
<cfset session.customerform.ccYear = Form.ccYear>
<cfset session.customerform.Shipping= Form.Shipping>
</cflock>
<div id="divHeaderText" class="page-content">
<div id="divHeaderLine1">Thank you for your Order </div>
#session.customerform.bFirstName#
#session.customerform.bLastName# !!</div>
<h2>Your Order number is <font color="red">
#randRange(Int, Int2, "SHA1PRNG")# </font></h2>
<h2><cfif #session.customerform.Shipping# is "OverNight">
Your order will arive in 12 hours since you opted for
Overnight shipping
</cfif>
<cfif #session.customerform.Shipping# is "OneDay">
Your order will arive in 1 day since you opted for One
Day shipping
</cfif>
<cfif #session.customerform.Shipping# is "TwoDay">
Your order will arive in 2 days since you opted for Two
Day shipping
</cfif></h2>
<h2>Your order will be shipped to the following address: <font
color="red">#session.customerform.sAddress# </font></h2>
</br>
</div>
<cflock timeout=20 scope="Session" type="Exclusive">
<cfset StructDelete(Session, "cart")>
</cflock>
</body>
</html>
&#13;
答案 0 :(得分:0)
快速浏览一下,'customerinfo.cfm'有两个问题:
<form>
标记。虽然有一个结束标记:</form>
。插入一个起始<form>
标记,并将表单操作定义为“reviewOrder.cfm”。将提交按钮更改为<input type="submit ...>
还有一件事:脚本标记结束(</script>
)在身体标记开始后出现!
希望这会有所帮助!