Saturday, May 23, 2015

ONLINE SHOPPING DATABASE APPLICATION

Aim:
            To create an online application using database access.

Algorithm:

  1. Create an ASP page which get details from the user.
  2. Create a database connection using ASP code.
  3. Compare the details of the user with the database.
  4. Get the amount from the user from payment gateway.
  5. Deliver the products the user to his/her address.




Program:


send.asp
<!--Copyright 2001 © by nima -->
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<style>
<!--
.lnk         { text-decoration: none; color: #FFFFFF; font-weight: bold }
-->
</style>
</head>

<body>
<%
 dim view
 view = request.querystring("view")
 if  view = "" then
    view = "view1.xsl"
 end if
%>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1" height="100">
  <tr>
    <td width="33%" colspan="2" height="81">
    <h1>XML Database</h1>
    </td>
    <td width="67%" colspan="2" height="81">&nbsp;</td>
  </tr>
  <tr>
    <td width="16%" align="center" dir="ltr" bgcolor="#336699" height="19">
    <a class="lnk" href="send.asp?view=view1.xsl">View1</a>
    </td>   
    <td width="17%" bgcolor="#336699" align="center" dir="ltr" height="19">
    <a class="lnk" href="send.asp?view=view2.xsl">View2</a></td>
    <td width="17%" bgcolor="#336699" align="center" height="19">&nbsp;</td>
    <td width="50%" bgcolor="#336699" align="center" height="19">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>

<%
    dim xmlhttp,xmlDom,xsldom,Query
    set xmlhttp=createobject("MSXML2.XMLHTTP")
    set xmlDom=createobject("MSXML2.domdocument")
    set xslDom=createobject("MSXML2.domdocument")
   
    xmldom.async=false
    xsldom.async=false

    query = "<main><sql>select * from product</sql></main>"

    xmlhttp.Open "POST","http://localhost/xmlDatabase/datasource.asp", false
    xmlhttp.send query
    if xmlhttp.status <> 200 then
       response.write "Error !!!"
   end if


   
    xmldom.load xmlhttp.responseXML
    xsldom.load server.mappath(".")+"/"+view
    response.write XMLDom.transformNode(XSLDom)
%>

<%
set xmlhttp = nothing
set xmldom= nothing
set xsldom = nothing
%>
</body>

</html>


datasource.asp
<% Option Explicit %>
<%Response.ContentType = "text/xml"%><?xml version="1.0"?>
<%
   dim xmlDom
   dim Conn,rs,fld,query
   set xmlDom=createobject("MSXML2.domdocument")
   Set Conn = server.CreateObject("adodb.connection")
   set rs = server.createobject("adodb.recordset")

   xmldom.load request
   query = xmldom.documentElement.childNodes(0).text
   Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+server.mappath(".")+"\database.mdb;Persist Security Info=False"
   rs.open query,conn,3,1
%>
<recordset total="<%=rs.recordcount%>">
<head>
<%for each fld in rs.fields%>
<field name="<%=fld.name%>"/>
<%next%>
</head>
<rows>
<%do until rs.eof%>
<row>
<%for each fld in rs.fields%>
<col><%=fld.value%></col>
<%next%>
</row>
<%rs.movenext%>
<%loop%>
</rows>
</recordset>
<%
rs.close
conn.close
set conn = nothing
set rs= nothing

set xmldom = nothing
%>

View1.xsl
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">

<table align = "center" border="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="80%" id="AutoNumber2" cellpadding="0">
         <xsl:for-each select="recordset/rows/row">
              <TR>
                 <xsl:apply-templates select="col"/>
              </TR>
          </xsl:for-each>
</table>
</xsl:template>
<xsl:template match="col">
             <TD><xsl:value-of select="."/></TD>
</xsl:template>
</xsl:stylesheet>



View2.xsl

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
              <tr>
                 <xsl:apply-templates select="recordset/head/field"/>
              </tr>
         <xsl:for-each select="recordset/rows/row">
              <TR>
                 <xsl:apply-templates select="col"/>
              </TR>
          </xsl:for-each>
</table>
</xsl:template>
<xsl:template match="col">
             <TD><xsl:value-of select="."/></TD>
</xsl:template>
<xsl:template match="recordset/head/field">
              <td bgcolor="#C0C0C0"><xsl:value-of select="./@name"/></td>
</xsl:template>
</xsl:stylesheet>















No comments:

Post a Comment