Tuesday, August 5, 2008

e-Mall Project code

Application.cfm

<cfapplication name="my"
sessionmanagement="yes">

<cfif IsDefined("form.remail")>


<cfquery name="q1" datasource="emall">
select * from reg where email = "#form.remail#" and p = "#form.pass#"
</cfquery>

<cfif #form.remail# eq #q1.email#>
<cfset session.name="#q1.name#">
<cfset session.id="#q1.regID#">
<cfset session.mail="#q1.email#">
</cfif>

</cfif>


To Display Logged User Name

<cfif isDefined("session.name")> (to check variable, session exist or not)
Hi #session.name#
<cfelse>
Hi
</cfif>

To Display Picture or other items for Logged User Only

<cfif isDefined("session.name")>
<div id="apDiv34"><a href="logout.cfm">
<img src="pic/logout_icon copy.jpg" width="50" height="47" /></a></div>
</cfif>





Query Build

<cfquery name="q1" datasource="emall">
select *from dvd
</cfquery>

Add Database Values and Picture to Table

<div id="apDiv21">

<table width="113" border="1">
<tr>
<cfoutput query="q1">
<td width="103">
<a href="viewdvd.cfm?dvdID=#q1.dvdID#">
(Passing Table values to viewdvd.cfm)
<img src="#q1.pic#" width="91" height="119" />
</a>
</td>
</cfoutput>
</tr>
<tr><cfoutput query="q1">
<td>
<div align="center"><span class="style2">#q1.title#</span></div></td>
(Assign database value to table)
</cfoutput>
</tr>
</table>

<div align="center"></div>
</div>




Get Particular Table Row and URL Values

<cfquery name="q1" datasource="emall">
select *from dvd where dvdID=#URL.dvdID#
</cfquery>


To Display Selected Item Details in another page

<div id="apDiv21">

<cfoutput query="q1">
<table border="1">
<tr>
<td width="77"><div align="center"><span class="style2">FILM NAME</span></div></td>
<td width="82"><span class="style2">#q1.title#</span></td>
<td width="221" rowspan ="4">

<img src="#q1.pic#" width="200" height="240" /> </td>
</tr>
<tr>
<td height="102"><span class="style2">STARRING</span></td>
<td><span class="style2">#q1.starring#</span></td>
</tr>
<tr>
<td height="91"><span class="style2">DIRECTOR</span></td>
<td><span class="style2">#q1.director#</span></td>
</tr>
<tr>
<td><div align="center"><span class="style2">PRICE</span></div></td>
<td><span class="style2">$#q1.price#</span></td>
</tr>

</table>
</cfoutput>
</div>


To Display Add to Cart Button if Logged User exist and Product ID , User ID passes to another page for Insertion

<cfif isDefined("session.name")>
<cfform name="form1" id="form1" method="post" action="addcart.cfm?pid=#q1.dvdID#&pname=#q1.title#">
<cfinput type="submit" name="Submit" value="Add to Cart">
</cfform>
</cfif>

To User Purchased Items and User ID in Database

<cfif (isDefined ("URL.pid")AND isDefined("URL.pname"))>
(Here to checking URL.variable exist or not)

<cfquery name="q2" datasource="emall">
insert into shop (userid, username, productid, productname) values (#session.id#,'#session.name#','#URL.pid#','#URL.pname#')
</cfquery>
</cfif>

No comments: