Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Shopping Cart

Status
Not open for further replies.

shawntbanks

Programmer
Oct 29, 2003
48
CA
I am trying to develop a shopping cart for a classified ad site, I know now that it is going to be different than a regular retail site, because I am selling I full description and not just a item. I want to be able to have a person enter all the information about a product including 4 pictures. then I want the customer to be able to view the ad and add more if they want to before they check out. Any help would be appricated
 
It kind of sounds like the issue isn't on the shopping cart side of things... but on the content management side... where users will be creating the ads.

That's where you need to start. Basically, you would store each ad as a separate record in a table in a database... that table would have columns for each of the four images, full description, title, username, etc etc... and one of those columns is going to store some sort of unique ID for that ad/item (whether it's created by you manually, or by the database engine as an auto-incrementing primary key or whatever).

Then your shopping cart would be a standard shopping cart, which is typically a ColdFusion structure stored in the session scope. This structure could be very simple... simply storing the quantity that the user is purchasing under a key that's equal to the unique id of the item.
In other words, if the user entered a quantity of "5" for item number "SCJ-072-082" and a quantity of "3" for item number "FNR-133-739", your shopping cart structure may simply be:
Code:
   ["SCJ-072-082"] = 5
   ["FNR-133-739"] = 3

But I think the majority of your development time is going to be on the user-entry/ad-creation end of things.

Make sense?


-Carl
 
I have the content management side where users will be creating the ads. I have them go through and put there information in but on the last page of there detail insertion, I am a little lost, and that is where the shoppong cart comes in. They will only be purchasing one of the same ad, but probably more than one ad of different types. As they enter there information I am storing it as Sission variables. I am having a little bit problem puting a picture in, because I am puting them in a folder on the server and they are being named after the saleitemid of the table which is a number that is being generated by the table when an ad is insertedl. I want them to be able to ad that information to a cart, and I guess what you are saying about just putting the itemid in sounds like it will work, but I am not too familuar with scopes. Any suggestings
 
Uhhh... hmmmm... so the shopping cart is for the people buying the ads??? I guess you'll have to give a little more detail about what you're trying to do.

If I'm a user, and I enter all the detail information about a product, then I specify what types of ads I want that product in (say "online banner ad - 480x60", "online banner ad - 125x125", "print ad - 2pg, 4 color")? I guess I'm a little confused why you would need a shopping cart for that. It'd pretty much just have to be a series of checkboxes on the last page, no?

Can you be a little more specific?


-Carl
 
I am new at this bare with me, here are some variables that i am setting, and after them I am letting the customer ad a picture if they want, then like a shopping cat let the customer review what they have ordered, delete it all together, or add another ad before they proceed to the payment process.

The information below is being inserted into a table in SQL and I am trying to put the pics in a folder with the file path in SQL with the rest of the information, having a little bit of problem trying to come up with some sort of naming schem. Anyway thanks for the time that you have spent looking at my problem, ant more suggestions would be appriciated.


<cfset session.auth.location = #form.community_list#>
<cfset session.auth.vehiclemake = #form.vehicle_make#>
<cfset session.auth.Vehiclemodel = #form.Vehicle_model#>
<cfset session.auth.itemYear = #form.vehicle_Year#>
<cfset session.auth.vehiclemileage = #form.vehicle_mileage#>
<cfset session.auth.shortdescription = #form.short_description#>
<cfset session.auth.longdescription = #form.long_description#>
<cfset session.auth.itemprice = #form.itemprice#>
<cfif #form.featured# NEQ &quot;&quot;>
<cfset session.auth.featured = #form.featured#></cfif>
<cfset session.auth.begindate = #form.begindate#>
<cfset session.auth.Enddate = #form.begindate#+#form.Enddate#>
 
I think I'm with you now.

Okay... it sounds like you're on the right track... you just need your shopping cart to hold more than one structure. The easiest way to do that is to turn your cart into an array, with each element in the array being a structure (similar to the structure you're already building).

So you'd do something like:
Code:
<CFSET strTempItem = StructNew()>

<CFSET strTempItem.location = form.community_list>
<CFSET strTempItem.vehiclemake = form.vehicle_make>
<CFSET strTempItem.Vehiclemodel = form.Vehicle_model>
<CFSET strTempItem.itemYear = form.vehicle_Year>
<CFSET strTempItem.vehiclemileage = form.vehicle_mileage>
<CFSET strTempItem.shortdescription = form.short_description>
<CFSET strTempItem.longdescription = form.long_description>
<CFSET strTempItem.itemprice = form.itemprice>
<CFIF Len(Trim(form.featured)) GT 0>
    <CFSET strTempItem.featured = form.featured>
</CFIF>
<CFSET strTempItem.begindate = form.begindate>
<CFSET strTempItem.Enddate = (form.begindate+form.Enddate)>

<CFLOCK timeout=&quot;30&quot;
        throwontimeout=&quot;No&quot;
        type=&quot;EXCLUSIVE&quot;
        scope=&quot;SESSION&quot;>
   <CFIF NOT IsDefined(&quot;SESSION.auth&quot;) OR NOT IsArray(SESSION.auth)>
       <CFSET SESSION.auth = ArrayNew(1)>
   </CFIF>

   <CFSET ArrayAppend(SESSION.auth,strTempItem)>
</CFLOCK>

Now, say, if the user has created 3 ads, there'll be 3 elements in the SESSION.auth array, each element containing a structure that describes that particular ad.

So
Code:
<CFOUTPUT>#SESSION.auth[2].vehiclemake#</CFOUTPUT>
would output the vehicle make of the second ad.

To insert the entire cart into your database, you'd just loop through the array elements:
Code:
<CFSET aryLocalCart = ArrayNew(1)>
<CFLOCK timeout=&quot;30&quot;
        throwontimeout=&quot;No&quot;
        type=&quot;READONLY&quot;
        scope=&quot;SESSION&quot;>
    <CFSET aryLocalCart = SESSION.auth>
</CFLOCK>
<CFLOOP from=&quot;1&quot; to=&quot;#ArrayLen(aryLocalCart)#&quot; index=&quot;whichAd&quot;>
    <CFQUERY name=&quot;insertAd&quot; ...>
       INSERT INTO tablename
       (location,vehiclemake,...) VALUES (#aryLocalCart[whichAd].location#,aryLocalCart[whichAd].vehiclemake#,...)
    </CFQUERY>
</CFLOOP>


Then, if they decide to delete their cart, you'd simply do:
Code:
<CFLOCK timeout=&quot;30&quot;
        throwontimeout=&quot;No&quot;
        type=&quot;EXCLUSIVE&quot;
        scope=&quot;SESSION&quot;>
   <CFIF IsDefined(&quot;SESSION.auth&quot;) AND IsArray(SESSION.auth)>
       <CFSET ArrayClear(SESSION.auth)>
   </CFIF>
</CFLOCK>

Does that get you any closer?


-Carl
 
Carl you have been a tremendous help, I am going to try that and I will get back to you soon, again Thanks
 
Actually I do have another question, i had mention about the picture problem. I am going to allow the customer to add up to 4 pictures to there ad. So I am going to upload them to my server when they send them, but I will have to rename them, so that they are unique to the ad, to you have any suggestions. I was at first adding them to the database and nameing them after the saleitem ID, but now that I am going to put them in to an array, I will have no reference to the next ID in the table. For example someone else could be placing an ad at the same time and retreive the same saleitem ID number so that wont work. to you have any suggestions on how to make them unique so when they are up loaded to the server folder they don't overwrite one another, and they are unique.


Thanks
 
In the cffile tag there is an attribute called &quot;nameconflict&quot;. The nameconflict allows you to choose from one of the four values: Error, Skip, Overwrite and Makeunique.

Use the Makeunique value.

Your cffile tag will look something like this:
<cffile action=&quot;UPLOAD&quot; nameconflict=&quot;MAKEUNIQUE&quot; ...>

After the file is stored on your server you can retrieve the name that was given to the file by using the &quot;ServerFile&quot; attribute. You will probably want to store that name in your database record that points to the image.
 
This is where I stand, but i get errors I want to make this in to a shopping cart




<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<cfparam name=&quot;form.selectlocal&quot; default=&quot;&quot;>
<cfset test = #form.selectlocal#>
<cfif #test# EQ &quot;&quot; or #test# EQ &quot;- Select SubCategory -&quot;>
<cflocation url=&quot;Ad_Placement_SubCat_Selection.cfm&quot; addtoken=&quot;yes&quot;>
</cfif>
<cfquery name=&quot;get_Communities&quot; datasource=&quot;Market&quot;>
SELECT *
FROM Communities
order by community
</cfquery>


<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>



<cfquery name=&quot;Categories&quot; datasource=&quot;market&quot;>
Select Categoryid, subcategory, subcategoryid, Category
from subandcat
where subcategoryid = #form.selectlocal#</cfquery>
<cfset Categoryids = Categories.Categoryid>
<cflock timeout=&quot;10&quot;><cfset Session.Subcategory = Categories.subcategory>
<cfset Session.Subcategoryid = Categories.subcategoryid></cflock>

<cfform action=&quot;Vehicle_Ad_Step2.cfm&quot; method=&quot;post&quot; name=&quot;Vehicles&quot;>

<input type=&quot;hidden&quot; value=&quot;#form.select_Ad_Subcategory#&quot;>
<table align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;5&quot; class=&quot;FormHeaders&quot;><div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#categories.Category#</cfoutput>
Details</font></div></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Subcategory:</font></td>
<td colspan=&quot;4&quot;><strong><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#Categories.subcategory#</cfoutput></font></strong></td>
</tr>
<tr>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Community:</font></td>
<td colspan=&quot;4&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<select name=&quot;Community_List&quot;>
<option></option>
<cfoutput query=&quot;Get_Communities&quot;>
<option value=&quot;#communityID#&quot;>#community#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td width=&quot;109&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name:</font></td>
<td colspan=&quot;4&quot;> <font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<CFinput name=&quot;Itemname&quot; type=&quot;text&quot; required=&quot;no&quot; message=&quot;Item Name Required&quot;>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Short
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Short_description&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;hard&quot; onChange=&quot;if (this.value.length > 100) {alert('The Short Description Cannot Be Greater Than 100 Chars.')};&quot;>Text entered here will be entered in the listings page</textarea>
</td>
</tr>
<tr>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Long
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Long_description&quot; cols=&quot;30&quot; rows=&quot;5&quot;>Text entered here will show up on your details page</textarea>
</td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Asking
Price:</font></td>
<td colspan=&quot;4&quot;> <CFinput name=&quot;itemprice&quot; value=&quot;&quot; type=&quot;text&quot; id=&quot;itemprice&quot; required=&quot;no&quot; message=&quot;Asking Price Required&quot; size=&quot;20&quot; maxlength=&quot;9&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><span >Featured
Item</span><font color=&quot;#FF0000&quot;>*</font></font></td>
<td colspan=&quot;4&quot;> <CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot; checked=&quot;yes&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Yes</font> </td>
<tr><td> </td><td colspan=&quot;4&quot;><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>No</font> </td></tr>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Start
Date Of Ad:</font></td>
<td colspan=&quot;4&quot;><cfinput name=&quot;begindate&quot; type=&quot;text&quot; validate=&quot;date&quot;></td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Length
Of Ad:</font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot; checked=&quot;yes&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>1
Week</font></td>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;> </font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>1
Month</font></td>
</tr></table>
<table align=&quot;center&quot;>
<tr><td colspan=&quot;5&quot;><BR><BR><div align=&quot;center&quot;><strong>Up to 4 pictures
can be submited with your ad</strong></div></td>
</tr>
<tr>
<td><strong>1:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_patha&quot;></td>
</tr>
<tr>
<td><strong>2:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathb&quot;></td>
</tr>
<tr>
<td><strong>3:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathc&quot;></td>
</tr>
<tr>
<td><strong>4:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathd&quot;></td>
</tr></tr>
<tr bgcolor=&quot;#FFFFFF&quot;>
<td colspan=&quot;5&quot;><div align=&quot;center&quot;>
<input type=&quot;submit&quot; value=&quot;Continue >>&quot; name=&quot;submit_upload&quot;>
</div></td>
</tr>
</table>


</cfform>


<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>



This is the action page
-------------------------------------------------------------------------------

<cfset strtempitem = structnew()>
<CFIF isdefined(&quot;form.submit_upload&quot;)>
<CFTRY>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_patha&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET strtempitem.picture1 = LISTLAST(FILE.SERVERFILE,'.')>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathb&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET strtempitem.picture2 = LISTLAST(FILE.SERVERFILE,'.')>


<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathc&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET strtempitem.picture3 = LISTLAST(FILE.SERVERFILE,'.')>


<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathd&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET strtempitem.picture4 = LISTLAST(FILE.SERVERFILE,'.')>

<CFCATCH></CFCATCH></CFTRY></cfif>



<cfset strtempitem.location = #form.community_list#>
<cfset strtempitem.itemname = #form.Itemname#>
<cfset strtempitem.shortdescription = #form.short_description#>
<cfset strtempitem.longdescription = #form.long_description#>
<cfset strtempitem.itemprice = #form.itemprice#>
<cfset strtempitem.featured = #form.featured#>
<cfset strtempitem.begindate = #form.begindate#>
<cfset strtempitem.Enddate = #form.begindate#+#form.Enddate#>
<cfset strtempitem.picture1 = #form.begindate#+#form.Enddate#>
<cfset strtempitem.picture2 = #form.begindate#+#form.Enddate#>
<cfset strtempitem.picture3 = #form.begindate#+#form.Enddate#>
<cfset strtempitem.picture4 = #form.begindate#+#form.Enddate#>

<cflock timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;exclusive&quot; scope=&quot;session&quot;>
<cfif not isdefined (&quot;session.auth2&quot;) or not isarray(session.auth2)>
</cfif>
<cfset arrayappend(session.auth2,strtempitem)>
</cflock>
 
What errors are you getting?

Toward the end of your OK page, I see:
Code:
<cfif not isdefined (&quot;session.auth2&quot;) or not isarray(session.auth2)>
             </cfif>

... but you're not doing anything within the CFIF block. You want that to be:
Code:
<cfif not isdefined (&quot;session.auth2&quot;) or not isarray(session.auth2)>
   <CFSET session.auth2 = ArrayNew(1)>
</cfif>

Other than that, it's difficult to see what's causing problems until we know exactly what error(s) ColdFusion is throwing.




-Carl
 
One other issue I see is the lines:
Code:
<CFSET strtempitem.picture1 = LISTLAST(FILE.SERVERFILE,'.')>

First, the variable name is officially CFFILE.SERVERFILE (the FILE.xxx syntax is now depricated).

But, secondly, I'm not at all sure what you're trying to do with the statement.
Code:
LISTLAST(&quot;#CFFILE.SERVERFILE#&quot;,&quot;.&quot;)
is going to return only the extension of the file... not the file name.

I'd recommend using
Code:
<CFSET strtempitem.picture1 = GetFileFromPath(CFFILE.SERVERFILE)>

As is, it wouldn't have thrown any errors that I can see, but it certainly wouldn't have given you the results you expected.

But we still need to know the error messages you are getting.


-Carl
 
On a side note -

You may be interested to know that when you reference vars when setting a new var, you do not have to use the octothorpe (#) if you are not using quotes. For example:

You currently have:
<cfset strtempitem.location = #form.community_list#>

When you can simply do:
<cfset strtempitem.location = form.community_list>

Another thing that caught my attention is the summation of dates that you apperantly are doing:
<cfset strtempitem.Enddate=#form.begindate#+#form.Enddate#>

If you are inserting that value into a db table where the field is a datetime data type, I believe you will get an error.

I admit that I do not know what you are trying to do, but if you are attempting to add two dates I must say that it is very suspicious.

 
Sorry it took me so long to respond.

The error that I am getting is:
__________________________________________________________________
An error occurred while evaluating the expression:


arrayappend(session.auth2,strtempitem)



Error near line 54, column 11.
--------------------------------------------------------------------------------

Error resolving parameter SESSION.AUTH2


The session variable AUTH2 does not exist. The cause of this error is very likely one of the following things:


The name of the session variable has been misspelled.
The session variable has not yet been created.
The session variable has timed out.


The error occurred while processing an element with a general identifier of (CFSET), occupying document position (54:5) to (54:50).
 
Yep... that would more than likely be because you didn't have the
Code:
<CFSET session.auth2 = ArrayNew(1)>
in your CFIF block, as I mentioned above.

So you say that error is fixed... did you have others? Or is everything working now?



-Carl
 
It seems to be working csteinhilber but what if on this page, when some one hits refresh it adds the same item and picture to the exicting cart, I have noticed this as i was testing. Everytime that I hit refresh, it put the pictures on the server, and added to the cart the same information. I am also trying to figure out how to limit the size of the images that are being sent to my server

If you would rather email me you can at sbanks@northstarpei.com


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>

<cfset strtempitem = structnew()>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_patha&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET strtempitem.picturea = GetFileFromPath(cffile.serverfile)>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathb&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET strtempitem.pictureb = GetFileFromPath(cffile.serverfile)>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathc&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET strtempitem.picturec = GetFileFromPath(cffile.serverfile)>

<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathd&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET strtempitem.pictured = GetFileFromPath(cffile.serverfile)>



<cfset strtempitem.subcategoryid = #form.subcategoryid#>
<cfset strtempitem.location = #form.community_list#>
<cfset strtempitem.itemname = #form.Itemname#>
<cfset strtempitem.shortdescription = #form.short_description#>
<cfset strtempitem.longdescription = #form.long_description#>
<cfset strtempitem.itemprice = #form.itemprice#>
<cfset strtempitem.featured = #form.featured#>
<cfset strtempitem.begindate = #dateformat(form.begindate, &quot;mmmm, dd yyyy&quot;)#>
<cfset strtempitem.Enddate = #dateformat(form.begindate + form.Enddate, &quot;mmmm, dd yyyy&quot;)#>


<cflock timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;exclusive&quot; scope=&quot;session&quot;>
<cfif not isdefined (&quot;session.auth2&quot;) or not isarray(session.auth2)>
<cfset session.auth2 = arraynew(1)>
</cfif>
</cflock>
<cfset arrayappend(session.auth2,strtempitem)>

<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder.cfm&quot;>


<td width=&quot;605&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>

<cfset arylocalcart = arraynew(1)>
<cflock timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
scope=&quot;session&quot;>
<cfset arylocalcart = session.auth2>
</cflock>
<table><cfloop from=&quot;1&quot; to=&quot;#arraylen(arylocalcart)#&quot; index=&quot;whichad&quot;><tr><td>
<!--- <cfoutput>#arylocalcart[whichad].subcategoryid#<br></cfoutput> --->
<cfoutput>#arylocalcart[whichad].location#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].itemname#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].shortdescription#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].longdescription#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].itemprice#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].featured#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].begindate#<br></cfoutput>
<cfoutput>#arylocalcart[whichad].Enddate#<br></cfoutput>
<cfoutput><img src=&quot;../sale_item_Images/#arylocalcart[whichad].Picturea#&quot;><br></cfoutput>
<cfoutput><img src=&quot;../sale_item_Images/#arylocalcart[whichad].Pictureb#&quot;><br></cfoutput>
<cfoutput><img src=&quot;../sale_item_Images/#arylocalcart[whichad].Picturec#&quot;><br></cfoutput>
<cfoutput><img src=&quot;../sale_item_Images/#arylocalcart[whichad].Pictured#&quot;><br></cfoutput>
</td></tr> </cfloop></table>




</tr>
<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>
 
Yes, what you're running into is a behavior of HTTP that we all pretty much hate... hitting refresh reposts all request headers. Unfortunately it's not something that ColdFusion really has control over.

There is a workaround that I've used to fix the issue, though. When it comes time to store the information in the array, you make sure it's unique (ie - not already in the array). And if it's not unique, then you ignore the post (assume that the user refreshed the page).

One pretty simple way to do that, I think, is to include a hidden field in your original form that get's plugged with a unique id:
Code:
<form ...>
    :
    <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;submitID&quot; value=&quot;#CreateUUID()#&quot;></CFOUTPUT>
    :
</form>
then, in your form submission processor, you check to make sure that that FORM.submitID hasn't already been submitted. There are any number of ways to do that... probably the easiest (since you're already accessing session scope) is to simply store a list of submitIDs in SESSION.

Code:
<CFSET bAcceptSubmit = false>
<CFLOCK timeout=&quot;30&quot;
        throwontimeout=&quot;No&quot;
        type=&quot;READONLY&quot;
        scope=&quot;SESSION&quot;>
	<CFIF LindFindNoCase(&quot;#SESSION.submittedIDs#&quot;,FORM.submitID) LTE 0>     
             <!--- the current submitID wasn't found in the list of previously submitted ids... so accept this submission --->
	     <CFSET bAcceptSubmit = true>
        </CFIF>
</CFLOCK>

<CFIF bAcceptSubmit>
   <cfset strtempitem.subcategoryid = #form.subcategoryid#>
   <cfset strtempitem.location = #form.community_list#>
             :
            
            
   <CFLOCK timeout=&quot;30&quot;    
           throwontimeout=&quot;no&quot;
           type=&quot;exclusive&quot;
           scope=&quot;session&quot;>
           <CFIF not IsDefined(&quot;session.auth2&quot;) or not IsArray(session.auth2)>
              <CFSET session.auth2 = arraynew(1)>
           </CFIF>
           <CFSET ArrayAppend(session.auth2,strtempitem)>
           <CFSET session.submittedIDs = ListAppend(&quot;#session.submittedIDs#&quot;,FORM.submitID)>
   </CFLOCK>

      :
</CFIF>
there are other ways, too... you can get as complex as you like... but you get the idea.


One comment about the code you posted, though. The first lock you're doing really isn't protecting what you need it to protect. You should lock every access to a shared variable scope. You create the lock, which is good, and use it to create the array if it doesn't exist... but the actual ArrayAppend is done outside of the lock... which isn't good. The ArrayAppend is an access of the session scope... so it really needs to be within the lock as well.
Code:
<CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;exclusive&quot;
        scope=&quot;session&quot;>
      <CFIF not IsDefined(&quot;session.auth2&quot;) or not IsArray(session.auth2)>
          <CFSET session.auth2 = arraynew(1)>
      </CFIF>
      <CFSET ArrayAppend(session.auth2,strtempitem)>
      <CFSET session.submittedIDs = ListAppend(&quot;#session.submittedIDs#&quot;,FORM.submitID)>
</CFLOCK>
rather than
Code:
<CFLOCK timeout=&quot;30&quot;    
        throwontimeout=&quot;no&quot;
        type=&quot;exclusive&quot;
        scope=&quot;session&quot;>
      <CFIF not IsDefined(&quot;session.auth2&quot;) or not IsArray(session.auth2)>
          <CFSET session.auth2 = arraynew(1)>
      </CFIF>
</CFLOCK>
<CFSET ArrayAppend(session.auth2,strtempitem)>





-Carl
 
Well I am back again I cant seem to get that to work with the refresh and all, and I am having problems with the fact of deleteing one item out of the bin, and modify an ad that is in the cart. I find it is dificult to do when I am inserting images as well, becuase they are being put into a folder on the server, so if i do allow them to change the image, the old on will still be left on the server.

___________________________________________________________________________

Here are the 3 pages I have so far.

PAGE1
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>
<cfset today = #now()# + 1>
<cfset Todays_Date = #dateformat(today, &quot;mm/dd/yyyy&quot;)#>

<cfquery name=&quot;get_Communities&quot; datasource=&quot;Market&quot;>
SELECT *
FROM Communities
order by location
</cfquery>

<cfquery name=&quot;get_SubCategories&quot; datasource=&quot;Market&quot;>
SELECT Category, categoryid, subcategory, subcategoryid
FROM subandcat
</cfquery>
<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder_Subcat_Select.cfm&quot;>
<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>




<cfform action=&quot;Ad_Placement_Step2.cfm&quot; method=&quot;post&quot; name=&quot;myform&quot; enctype=&quot;multipart/form-data&quot;>
<cfoutput><input type=&quot;hidden&quot; name=&quot;submitID&quot; value=&quot;#createUUID()#&quot;></cfoutput>
<input type=&quot;hidden&quot; value=&quot;#form.select_Ad_Subcategory#&quot; name=&quot;subcategoryid&quot;>
<input type=&quot;hidden&quot; value=&quot;#categoryids&quot; name=&quot;CategoryID&quot;>
<table align=&quot;center&quot; border=&quot;0&quot;>
<tr>
<td colspan=&quot;5&quot; class=&quot;FormHeaders&quot;><div align=&quot;center&quot;><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><!--- <cfoutput>#categories.Category#</cfoutput> --->
Details</font></div></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Category:</font></td>
<td valign=&quot;top&quot; colspan=&quot;4&quot;>
<select name=&quot;select_Ad_Subcategory&quot; onchange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<option>- Select Category-</option>
<!--- again, use the group attribute to group output by category --->
<cfoutput query=&quot;get_SubCategories&quot; group=&quot;Category&quot;>
<option value=&quot;#Categoryid#&quot;>#Category#</option>
</cfoutput>
</select></td></tr>
<tr><td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Subcategory:</font></td>
<td colspan=&quot;4&quot;> <select name=&quot;selectLocal&quot; onChange=&quot;whichLocal(this.form)&quot; size=&quot;1&quot;>
<option>- Select SubCategory -</option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
<option></option>
</select></td>
</tr>

<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Community:</font></td>
<td colspan=&quot;4&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>
<select name=&quot;Community_List&quot;>

<option></option>
<cfoutput query=&quot;Get_Communities&quot;>
<option value=&quot;#location#&quot;>#location#</option>
</cfoutput>
</select>
</font></td>
</tr>
<tr>
<td width=&quot;109&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Item
Name:</font></td>
<td colspan=&quot;4&quot;> <font face=&quot;Georgia, Times New Roman, Times, serif&quot;>

<CFinput name=&quot;Itemname&quot; type=&quot;text&quot; required=&quot;no&quot; message=&quot;Item Name Required&quot;>
</font></td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Short
Description:</font></td>
<td colspan=&quot;4&quot;>
<textarea name=&quot;Short_description&quot; cols=&quot;30&quot; rows=&quot;5&quot; wrap=&quot;hard&quot; onChange=&quot;if (this.value.length > 100) {alert('The Short Description Cannot Be Greater Than 100 Chars.')};&quot;>Text entered here will be entered in the listings page</textarea>

</td>
</tr>
<tr>
<td valign=&quot;top&quot; ><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Long
Description:</font></td>
<td colspan=&quot;4&quot;><textarea name=&quot;Long_description&quot; cols=&quot;30&quot; rows=&quot;5&quot;>Text entered here will show up on your details page</textarea>

</td>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Asking
Price:</font></td>
<td colspan=&quot;4&quot;><CFinput name=&quot;itemprice&quot; value=&quot;&quot; type=&quot;text&quot; id=&quot;itemprice&quot; required=&quot;no&quot; message=&quot;Asking Price Required&quot; size=&quot;20&quot; maxlength=&quot;9&quot;>

</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;><span >Featured
Item</span><font color=&quot;#FF0000&quot;>*</font></font></td>
<td colspan=&quot;4&quot;> <CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;1&quot; checked=&quot;yes&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Yes</font> </td>
<tr><td> </td><td colspan=&quot;4&quot;><CFinput name=&quot;featured&quot; type=&quot;radio&quot; id=&quot;featured&quot; value=&quot;0&quot;>
<font size=&quot;-2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>No</font> </td></tr>
</tr>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Start
Date Of Ad:</font></td>
<td colspan=&quot;4&quot;><cfinput name=&quot;begindate&quot; type=&quot;text&quot; validate=&quot;date&quot; value=&quot;#Todays_Date#&quot;>
</td>
</tr>
<tr>
<td valign=&quot;top&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Length
Of Ad:</font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;7&quot; checked=&quot;yes&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>7
Days</font></td>
<tr bgcolor=&quot;#EDECE0&quot;>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;> </font></td>
<td><CFinput name=&quot;Enddate&quot; type=&quot;radio&quot; value=&quot;30&quot;></td>
<td><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>30 Days
</font></td>
</tr></table>

<table align=&quot;center&quot;>
<tr><td colspan=&quot;5&quot;><BR><BR><div align=&quot;center&quot;><strong>Up to 4 pictures
can be submited with your ad</strong></div></td>
</tr>
<tr>
<td><strong>1:</strong></td>

<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_patha&quot;></td>

</tr>
<tr>
<td><strong>2:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathb&quot;></td>
</tr>
<tr>
<td><strong>3:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathc&quot;></td>
</tr>
<tr>
<td><strong>4:</strong></td>
<td colspan=&quot;4&quot;><INPUT type=&quot;file&quot; name=&quot;file_pathd&quot;></td>
</tr></tr>
<tr bgcolor=&quot;#FFFFFF&quot;>
<td colspan=&quot;5&quot;><div align=&quot;center&quot;>
<input type=&quot;submit&quot; value=&quot;Continue >>&quot; name=&quot;submit_upload&quot;>
</div></td>
</tr>
</table>


</cfform>


<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>

PAGE2


<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>

<CFQUERY NAME=&quot;vendorInfo&quot; DATASOURCE=&quot;market&quot;>
select *
from vendors
where vendorid = #SESSION.Auth.vendorID#
</cfquery>
<cfset session.strtempitem = structnew()>
<cfif file_patha NEQ &quot;&quot;>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_patha&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET session.strtempitem.picturea = GetFileFromPath(cffile.serverfile)></cfif>
<cfif file_pathb NEQ &quot;&quot;>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathb&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\<CFSET session.strtempitem.pictureb = GetFileFromPath(cffile.serverfile)></cfif>
<cfif file_pathc NEQ &quot;&quot;>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathc&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET session.strtempitem.picturec = GetFileFromPath(cffile.serverfile)></cfif>
<cfif file_pathd NEQ &quot;&quot;>
<CFFILE action=&quot;UPLOAD&quot; nameconflict=&quot;makeunique&quot; filefield=&quot;file_pathd&quot; accept=&quot;image/*&quot; destination=&quot;C:\Inetpub\ <CFSET session.strtempitem.pictured = GetFileFromPath(cffile.serverfile)></cfif>


<cfset session.strtempitem.categoryid = #form.select_Ad_Subcategory#>
<cfset session.strtempitem.subcategoryid = #form.selectLocal#>
<cfset session.strtempitem.location = #form.community_list#>
<cfset session.strtempitem.itemname = #form.Itemname#>
<cfset session.strtempitem.shortdescription = #form.short_description#>
<cfset session.strtempitem.longdescription = #form.long_description#>
<cfset session.strtempitem.itemprice = #form.itemprice#>
<cfset session.strtempitem.featured = #form.featured#>
<cfset session.strtempitem.begindate = #dateformat(form.begindate, &quot;mm/dd/yyyy&quot;)#>
<cfset session.strtempitem.Enddate = #dateformat(form.begindate + form.Enddate, &quot;mm/dd/yyyy&quot;)#>
<cfparam name=&quot;form.selectlocal&quot; default=&quot;&quot;>
<cfset test = #form.selectlocal#>
<cfif #test# EQ &quot;&quot; or #test# EQ &quot;- Select SubCategory -&quot;>
<cflocation url=&quot;Ad_Placement.cfm?id=1&quot;>
</cfif>



<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder.cfm&quot;>


<td width=&quot;605&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>

<table border=&quot;0&quot;><tr><td colspan=&quot;2&quot; class=&quot;LongDesc&quot;><div align=&quot;center&quot;> <div align=&quot;center&quot;><a href=&quot;Ad_Placement_Step3.cfm&quot;>Add
To Cart</a></div></td></tr>
<tr><td colspan=&quot;2&quot;><HR><BR><BR></td></tr>
<tr>
<td valign=&quot;bottom&quot;><cfoutput>
<div align=&quot;left&quot;><font face=&quot;Georgia, Times New Roman, Times, serif&quot;>Information
On </font><font size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#session.strtempitem.Itemname# and #session.strtempitem.subcategoryid# and #session.strtempitem.categoryid#</font></div>
</cfoutput></td>
</tr>
<tr>
<td>
<tr>
<td><table border=&quot;0&quot;>
<tr>
<cfif file_patha NEQ &quot;&quot;>
<td width=&quot;106&quot;>

<img src=&quot;../sale_item_Images/<cfoutput>#session.strtempitem.picturea#</cfoutput>&quot; alt=&quot;Click on picture to enlarge&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>

</td>
</cfif>
<cfif file_pathb NEQ &quot;&quot;>
<td width=&quot;106&quot;>

<img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/<cfoutput>#session.strtempitem.pictureb#</cfoutput>&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>

</td>
</cfif>
<cfif file_pathc NEQ &quot;&quot;>
<td width=&quot;106&quot;>

<img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/<cfoutput>#session.strtempitem.picturec#</cfoutput>&quot;width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;>
</td>
</cfif>
<cfif file_pathd NEQ &quot;&quot;>
<td width=&quot;106&quot;>
<img alt=&quot;Click on picture to enlarge&quot; src=&quot;../sale_item_Images/<cfoutput>#session.strtempitem.pictured#</cfoutput>&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot; >
</td>
</cfif>
</tr>
</table></td>
</tr>
<tr>
<td > <table>
<tr>
<td width=&quot;269&quot; bgcolor=&quot;#339900&quot;><strong><font size=&quot;3&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Price</font></strong></td>
<td width=&quot;310&quot; bgcolor=&quot;#339900&quot; colspan=&quot;4&quot;><div align=&quot;center&quot;><font size=&quot;3&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><strong>Location</strong></font></div></td>
</tr>
<cfoutput>
<tr>
<td class=&quot;FormText&quot;><strong>#Dollarformat(session.strtempitem.itemPrice)#</strong></td>
<td colspan=&quot;4&quot;> <div align=&quot;center&quot;>#session.strtempitem.Location#</div></td>
</tr>
</cfoutput></table></td>
</tr>
<tr>
<td><table>
<tr><cfoutput>
<td width=&quot;361&quot; bgcolor=&quot;EDECE0&quot; class=&quot;LongDesc&quot;>#session.strtempitem.longdescription#</td>
</cfoutput> <cfoutput query=&quot;vendorInfo&quot;>
<td width=&quot;212&quot;><div align=&quot;center&quot;>
<p class=&quot;LongDesc&quot;>For more information, contact:<br>
<strong><a href=&quot;mailto:#email#&quot;>#email#</a></strong></p>
</div></td>
</cfoutput></tr>
</table></td>
</tr>
<tr>
<td colspan=&quot;2&quot;><BR><BR><HR></td>
</tr>
<tr>
<td colspan=&quot;2&quot; class=&quot;LongDesc&quot;><div align=&quot;center&quot;><a href=&quot;Ad_Placement_Step3.cfm&quot;>Add
To Cart</a></div></td>
</tr>
</table>



</tr>
<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>


PAGE3
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html>




<cflock timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;exclusive&quot; scope=&quot;session&quot;>
<cfif not isdefined (&quot;session.auth2&quot;) or not isarray(session.auth2)>
<cfset session.auth2 = arraynew(1)>
</cfif>

<cfset arrayappend(session.auth2,session.strtempitem)>

</cflock>

<cfinclude template=&quot;../Templates/Header_&_Sidebar_for_Place_Ad_Folder.cfm&quot;>


<td width=&quot;600&quot; rowspan=&quot;2&quot; valign=&quot;top&quot; bgcolor=&quot;#FFFFFF&quot;>

<table border=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td colspan=&quot;5&quot;><font color=&quot;#669933&quot; size=&quot;4&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>My
Shopping Cart</font><img src=&quot;../Images/cart.gif&quot;>
<hr></td>
<tr>
<td colspan=&quot;5&quot;><strong><font size=&quot;2&quot;>Please note: Every ad,
including pictures, will be reviewed for ethical content upon
activation. Any ads found to contain unethical content will
be deleted without a refund.</font></strong></td>
</tr>
<form action=&quot;Payment Inforamtion&quot; method=&quot;post&quot;>
<tr>
<td colspan=&quot;5&quot;><BR>
<BR> <div align=&quot;center&quot;>
<input type=&quot;submit&quot; value=&quot;Pay For Listings&quot;>
</div></td>
</tr>
</form>
<tr>
<td width=&quot;154&quot;></td>
<td width=&quot;69&quot;><div align=&quot;center&quot;>Item Listed</div></td>
<td width=&quot;91&quot;><div align=&quot;center&quot;>Asking Price</div></td>
<td width=&quot;91&quot;><div align=&quot;center&quot;>Listing Fee</div></td>
<td width=&quot;163&quot;></td>
</tr><cfset arylocalcart = arraynew(1)>
<cflock timeout=&quot;30&quot;
throwontimeout=&quot;no&quot;
type=&quot;readonly&quot;
scope=&quot;session&quot;><cfset arylocalcart = session.auth2>
</cflock>
<cfloop from=&quot;1&quot; to=&quot;#arraylen(arylocalcart)#&quot; index=&quot;whichad&quot;>
<cfoutput><tr>
<td width=&quot;154&quot;></td>
<td width=&quot;69&quot;><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#arylocalcart[whichad].itemname#</font></div></td>
<td width=&quot;91&quot;><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>#dollarformat(arylocalcart[whichad].itemprice)#</font></div></td>
<td width=&quot;91&quot;><div align=&quot;center&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>$30.00</font></div></td>
<td><a href=&quot;Modify_Ad.cfm&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>[Modify]</font></a>   <a href=&quot;Delete_Ad.cfm&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>[Delete]</font></a></td>
<td width=&quot;163&quot;></td>
</tr></cfoutput></cfloop><tr><td colspan=&quot;5&quot;><hr></td></tr>
<tr><cfset subtotal = #arraylen(arylocalcart)# * 30>
<cfset taxes = #subtotal# * 0.177>
<cfset total = #subtotal# + #taxes#>
<td></td><td></td><td><BR><BR><div align=&quot;right&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Total
Listing Fee:</font></div></td>
<td valign=&quot;bottom&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#dollarformat(subtotal)#</cfoutput></font></td>
<td></td>
</tr>
<tr>
<td></td><td></td><td><div align=&quot;right&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Applicable Tax:</font></div></td>
<td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#dollarformat(taxes)#</cfoutput></font></td>
<td></td>
</tr>
<tr>
<td></td><td></td><td><div align=&quot;right&quot;><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;>Total
:</font></div></td><td><font size=&quot;2&quot; face=&quot;Georgia, Times New Roman, Times, serif&quot;><cfoutput>#dollarformat(Total)#</cfoutput></font></td><td></td>
</tr>
</table>




</tr>
<tr>
<td background=&quot;../images/top_space2.gif&quot;><img src=&quot;../images/top_space2.gif&quot;></td>
</tr>
</table>
</td></tr>
</table>

</body>
</html>
 
Shawn,
You seem to be in this mode of randomly (and incorrectly) adding code to your pages to try to get them to work.

I think what you need to do is take a step back and create a much smaller sample system for a little practice until you understand all the concepts that have been discussed here... then you can begin to add functionality until you're back up to your full-blown cart that satisfies all your requirements.

Here are three files that make up a much less complex shopping cart with most of the solutions offered here. I'd suggest putting them on your server in a new directory and trying them out. They should work out-of-the-box as written (or with very little editing). See how they work. Deconstruct them and see what's doing what. Experiment with them. THEN start to add in the rest of your specific functionality.

page1.cfm
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
	<title>Submit Ad</title>
</head>

<body>

<form action=&quot;page2.cfm&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;>
   
<p>Item name:&nbsp;<input name=&quot;itemname&quot; type=&quot;text&quot;></p>

<p>Category:&nbsp;
<select name=&quot;category&quot;>
<option value=&quot;&quot;> - SELECT A CATEGORY - </option>
<option value=&quot;1&quot;>Category 1</option>
<option value=&quot;2&quot;>Category 2</option>
</select>
</p>
<p>Images:<br />
1 - <input type=&quot;file&quot; name=&quot;picture1&quot; accept=&quot;image/gif,image/jpeg&quot;><br />
2 - <input type=&quot;file&quot; name=&quot;picture2&quot; accept=&quot;image/gif,image/jpeg&quot;><br />
</p>

<!--- create our hidden field with a unique id to prevent an ad from getting into the shopping cart more than once --->
<CFOUTPUT><input type=&quot;hidden&quot; name=&quot;submitid&quot; value=&quot;#CreateUUID()#&quot;></CFOUTPUT>

<input type=&quot;submit&quot;>
</form>


</body>
</html>



page2.cfm
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
	<title>Confirm Ad</title>
</head>

<body>

<!--- did the user get here from the ad submission page? --->
<CFIF IsDefined(&quot;FORM&quot;) AND IsStruct(FORM) AND NOT StructIsEmpty(FORM) AND IsDefined(&quot;FORM.submitid&quot;)>
        <!--- yes, the user got here from the form --->

	<CFSET bValidSubmit = true>
        <!--- lock the session scope and check the list of previously submitted submitIDs... if there's a match, the submission is not valid --->
	<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
		<CFIF IsDefined(&quot;session.submittedIDs&quot;) AND ListFind(&quot;#session.submittedIDs#&quot;,FORM.submitID) GT 0>
			<CFSET bValidSubmit = false>
		</CFIF>
	</CFLOCK>

        <!--- only proceed if an ad with this submitID hasn't already been submitted --->
	<CFIF bValidSubmit>
                <!--- set up some directory variables --->
		<CFSET webRootDirectory = &quot;C:\Inetpub\[URL unfurl="true"]wwwroot\website&quot;>[/URL]
		<CFSET pictureDirectory = &quot;\market\sale_item_Images\&quot;>
		<CFSET picture1filename = &quot;&quot;>
		<CFSET picture2filename = &quot;&quot;>
		
                <!--- upload the pictures as appropriate --->
		<CFIF Len(Trim(FORM.picture1)) GT 0>
			<CFFILE action=&quot;UPLOAD&quot;  nameconflict=&quot;makeunique&quot; filefield=&quot;picture1&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
			<CFSET picture1filename = GetFileFromPath(CFFILE.serverfile)>
		</CFIF>
		<CFIF Len(Trim(FORM.picture2)) GT 0>
			<CFFILE action=&quot;UPLOAD&quot;  nameconflict=&quot;makeunique&quot; filefield=&quot;picture2&quot; accept=&quot;image/*&quot; destination=&quot;#webRootDirectory##pictureDirectory#&quot;>
			<CFSET picture2filename = GetFileFromPath(CFFILE.serverfile)>
		</CFIF>
		
		
                <!--- display the ad and ask for confirmation that the user wants to actually add it to their cart... behind the scenes, construct a form with hidden fields to pass all the relevent data to the next page --->
		Here's the ad you've submitted:
		
		<form action=&quot;page3.cfm&quot; method=&quot;post&quot;>
		
		<p>Item Name: <CFOUTPUT>#FORM.itemname#<input type=&quot;hidden&quot; name=&quot;itemname&quot; value=&quot;#FORM.itemname#&quot;></CFOUTPUT></p>
		
		<p>Category: <CFOUTPUT>#FORM.category#<input type=&quot;hidden&quot; name=&quot;category&quot; value=&quot;#FORM.category#&quot;></CFOUTPUT></p>
		
		<p>Images:<br />
		<CFIF Len(Trim(picture1filename)) GT 0>
		   <CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;#pictureDirectory##picture1filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;><input type=&quot;hidden&quot; name=&quot;picture1filename&quot; value=&quot;#picture1filename#&quot;></CFOUTPUT><br />
		</CFIF>
		<CFIF Len(Trim(picture2filename)) GT 0>
		   <CFOUTPUT><img alt=&quot;Click on picture to enlarge&quot; src=&quot;#pictureDirectory##picture2filename#&quot; width=&quot;100&quot; height=&quot;70&quot; border=&quot;0&quot;><input type=&quot;hidden&quot; name=&quot;picture2filename&quot; value=&quot;#picture2filename#&quot;></CFOUTPUT><br />
		</CFIF>
		</p>
		
		<CFOUTPUT><input type=&quot;hidden&quot; name=&quot;submitid&quot; value=&quot;#FORM.submitid#&quot;></CFOUTPUT>
		
		<input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Add to cart&quot;>
		
		</form>
	<CFELSE>
           <!--- the submitID was found in the list of previously submitted ads... so this submission is not valid --->
	   You've already submitted this ad. <a href=&quot;page3.cfm&quot;>Click here</a> to view your cart.
	
	</CFIF>
<CFELSE>
        <!--- no... the user must've gotten here by mistake (no form was submitted), so take them back to page 1 --->
	<CFLOCATION url=&quot;page1.cfm&quot;>
</CFIF>


</body>
</html>



page3.cfm
Code:
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>

<html>
<head>
	<title>View Shopping Cart</title>
</head>

<body>

<!--- did the user get here from the ad confirmation page? --->
<CFIF IsDefined(&quot;FORM&quot;) AND IsStruct(FORM) AND NOT StructIsEmpty(FORM) AND IsDefined(&quot;FORM.submitid&quot;)>
	<CFSET bValidSubmit = true>

        <!--- lock the session scope and check the submitID against the list of previously submitted ads... again --->
	<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
		<CFIF IsDefined(&quot;session.submittedIDs&quot;) AND ListFind(&quot;#session.submittedIDs#&quot;,FORM.submitID) GT 0>
			<CFSET bValidSubmit = false>
		</CFIF>
	</CFLOCK>

	<CFIF bValidSubmit>
                <!--- if it's a new submitID, create the temporary structure (NOT in the session scope ---> 
 		<CFSET strTempItem = StructNew()>
		
		<CFSET strTempItem.itemname = FORM.itemname>
		<CFSET strTempItem.category = FORM.category>
		
		
		<CFSET strTempItem.picture1 = &quot;&quot;>
		<CFSET strTempItem.picture2 = &quot;&quot;>
		
		<CFIF IsDefined(&quot;FORM.picture1filename&quot;) AND Len(Trim(FORM.picture1filename)) GT 0>
			<CFSET strTempItem.picture1 = FORM.picture1filename>
		</CFIF>
		<CFIF IsDefined(&quot;FORM.picture2filename&quot;) AND Len(Trim(FORM.picture2filename)) GT 0>
			<CFSET strTempItem.picture2 = FORM.picture2filename>
		</CFIF>

                <!--- then lock the session scope and append the new ad to the shopping cart and update the list of previously submitted IDs with the current submitID --->
		<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;EXCLUSIVE&quot; scope=&quot;SESSION&quot;>
           <CFIF NOT IsDefined(&quot;session.auth&quot;) or NOT IsArray(session.auth)>
              <CFSET session.auth = arraynew(1)>
           </CFIF>
           <CFSET ArrayAppend(session.auth,strTempItem)>
		   <CFIF NOT IsDefined(&quot;session.submittedIDs&quot;)>
              <CFSET session.submittedIDs = &quot;&quot;>
           </CFIF>
           <CFSET session.submittedIDs = ListAppend(&quot;#session.submittedIDs#&quot;,FORM.submitID)>
		</CFLOCK>
		

	<CFELSE>
           <!--- the submitID already exists in the list of previously submitted IDs, so this submission is not valid --->
	   <p>You've already added this item to your cart.</p>
	
	</CFIF>
</CFIF>

<!--- regardless of any of the above, display the current cart --->
<p>Here's your shopping cart:<br />

<CFSET aryLocalArray = ArrayNew(1)>
<!--- readonly lock on the session scope, and copy out the session array to a local array... since we really don't want to keep the lock open while we're looping --->
<CFLOCK timeout=&quot;30&quot; throwontimeout=&quot;No&quot; type=&quot;READONLY&quot; scope=&quot;SESSION&quot;>
	<CFIF IsDefined(&quot;session.auth&quot;) AND IsArray(session.auth)>
		<CFSET aryLocalArray = session.auth>
	</CFIF>
</CFLOCK>

<!--- output the cart contents using the local (NOT session scope) array --->
<table border=&quot;1&quot; cellpadding=&quot;5&quot;>
<tr bgcolor=&quot;#000000&quot; style=&quot;color: #FFFFFF;&quot;><td>Item #</td><td>Item Name</td><td>Category</td></tr>
<CFIF ArrayLen(aryLocalArray) GT 0>
<CFLOOP from=&quot;1&quot; to=&quot;#ArrayLen(aryLocalArray)#&quot; index=&quot;whichItem&quot;>
	<CFOUTPUT><tr><td>#whichItem#</td><td>#aryLocalArray[whichItem].itemname#</td><td>#aryLocalArray[whichItem].category#</td></tr></CFOUTPUT>
</CFLOOP>
<CFELSE>
	<tr><td colspan=&quot;3&quot;>No items currently in cart</td></tr>
</CFIF>
</table>

<p><a href=&quot;page1.cfm&quot;>Click here</a> to add a new item</p>


</body>
</html>

That should get you going. I'd thoroughly suggest buying a good ColdFusion book as well... maybe ColdFusion Web Application Construction Kit... as it sounds like you don't quite have a handle on some of the more basic ColdFusion concepts and need a little more background information. What you're trying to develop here is a pretty complex project. And it's going to be very frustrating for you to try to get it to work if you don't really understand the code we're trying to give you to solve your problems.


-Carl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top