Avatar billede need-help-2 Nybegynder
25. oktober 2003 - 12:39 Der er 1 løsning

Ændring fra database til e-mail

Kære Eksperter

Jeg har downloaded et shopsystem for nyligt og jeg vil gerne have lavet nogle ændringer. Problemet er, at i det nuværende system bliver alle bestillinger skrevet til en database ved bestillingssiden. Jeg vil gerne have bestillingen skrevet til en e-mail samtidig, selvfølgelig med alle de samme variabler så jeg kan se hvad og hvem, som der har bestilt.

Nedenfor er ASP-koden til bestillingssiden, da jeg formoder at det er her der skal laves lidt om. Jeg håber, at nogle af jer programmeringsguruer har mod på at hjælpe mig.

---ASP-kode start---

<%@ Language=VBScript %>
<% pageTitle = "Check-Out" %>
<!-- #include file="db.asp" -->
<!-- #include file="adovbs.inc" -->

<%

   
    set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConString

    if cstr(Session("orderID")) = "" then
%>

<html>
<head>
<meta name="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title><%= pageTitle %></title>
<style type="text/css">
<!--
a:link      { color: #808080 }
a:visited    { color: #808080 }
a:hover      { color: #ff9900 }
-->
</style>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" text="#808080">
<basefont face="Verdana" size="2">
<table border="0" width="100%" cellpadding="4" cellspacing="1">
  <tr>
    <td valign="top" nowrap><img border="0" src="images/mcartfree.gif" WIDTH="249" HEIGHT="64"></td>
    <td valign="bottom" nowrap align="right"><font face="Verdana" size="1">&nbsp;</font></td>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#666666" height="20" align="left" valign="middle" nowrap colspan="4">&nbsp;<font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><a style="color: #FFFFFF; text-decoration: none" href="http://www.metalinks.com/default.htm"><img src="images/icon.gif" border="0" align="middle" WIDTH="16" HEIGHT="16"> metalinks.com</a>&nbsp;|
      <b>&nbsp;<a href="default.asp" style="color:#FFFFFF;text-decoration:none;">Home</a>&nbsp;|
      &nbsp;<a href="mailto:webmaster@yourdomain.com" style="color:#FFFFFF;text-decoration:none;">Customer
      Service</a>&nbsp; |&nbsp;<a href="reviewOrder.asp" style="color:#FFFFFF;text-decoration:none;">View
      Cart</a></b> |&nbsp;<a href="search.asp" style="color:#FFFFFF;text-decoration:none;">
      Product Search</a></b></font></td>
  </tr>
</table>
<hr color="#CCCCCC" size="1" noshade>
<table border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" width="625">
  <tr>
    <td width="128" valign="top" align="center">
      <table border="0" cellspacing="4" cellpadding="4" width="125">
        <tr>
          <td width="128" bgcolor="#FFFFFF"><b><font color="#ff9900" size="3" face="Arial"><i>Live
            Demo</i></font></b><br>
            <br>
            <font face="Verdana" color="#808080" size="1">This store and
            its products are for demonstration purposes only. You cannot
            actually purchase any of the products, nor is there a secure server
            to process your order.</font><br>
            <br>
            <br>
           
            <font face="Verdana" size="2" color="#808080"><a href="moreinfo.asp"><br>
            <b>More info</b><br>
            </a><a href="mailto:webmaster@metalinks.com"><b>Contact us</b></a></font><br>
          </td>
        </tr>
      </table>
    <td width="1" bgcolor="#000000"><img src="images/spacer.gif" width="1" height="1" alt border="0"></td>
   
    <td align="center" valign="middle"><table border="0" cellspacing="4" cellpadding="4"><tr><td>         

<%
        Response.Write "<p><font face='Verdana' size='3'><b>"
        Response.Write "There is no current order.  If you had "
        Response.Write "added items previously to your order, "
        Response.Write "your session may have timed out.<br><br>"
        Response.Write "<a href='default.asp'>Continue Shopping</a>"
        Response.Write "<b></font></p>"
%>
</td>
  </tr>
  </table>       
</td>
  </tr>
  </table>
    <hr color="#CCCCCC" size="1" noshade>
     
<table border="0" cellpadding="0" cellspacing="6" width="100%"> 
  <tr>
    <td colspan="3" valign="BOTTOM"><font face="Verdana, Arial, Helvetica" size="1">     
     
      Last Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%A, %B %d, %Y" startspan -->Saturday, July 07, 2001<!--webbot bot="Timestamp" endspan i-checksum="49640" -->
      <br>
      Powered by <a href="http://metalinks.com/metacart.htm">MetaCart</a>,
      ©2000-2002 <a href="http://metalinks.com/">MetaLinks.com</a><br>
      </font></td>
  <td colspan="3" align="right" valign="TOP">&nbsp;
  </td>
  </tr>
</table>
</body>
</html>
<% 
else
       
        intOrderID = cstr(Session("orderID"))

        set rsProd = Server.CreateObject("ADODB.Recordset")
        rsProd.Open "SELECT * FROM itemsOrdered " _
            & "WHERE orderID="& intOrderID, _
            Conn, adOpenDynamic, adLockPessimistic, adCmdText
        while not rsProd.EOF

            element = "quant" & rsProd("productID")
            intQuant = Request.form(element)

            if intQuant <> "" and isNumeric(intQuant) then
                if intQuant = 0 then
                    rsProd.Delete
                else
                    rsProd("quantity") = intQuant
                end if
            end if
            rsProd.Update
            rsProd.MoveNext
        wend

        if Request.form("control") = "Update Order" then

            rsProd.Close
            set rsProd = Nothing
   
            Conn.Close
            set Conn = Nothing

            Response.Redirect "reviewOrder.asp"
        else
       
        if rsProd.BOF and rsProd.EOF then
                rsProd.Close
                set rsProd = Nothing
           
                Conn.Close
                set Conn = Nothing
               
                Session("orderID") = ""
                Response.Redirect "checkout.asp"
           
        else
%>
<html>
<head>
<meta name="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title><%= pageTitle %></title>

<style type="text/css">
<!--
a:link      { color: #808080 }
a:visited    { color: #808080 }
a:hover      { color: #ff9900 }
-->
</style>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" text="#808080">
<basefont face="Verdana" size="2">
<table border="0" width="100%" cellpadding="4" cellspacing="1">
  <tr>
    <td valign="top" nowrap><img border="0" src="images/mcartfree.gif" WIDTH="249" HEIGHT="64"></td>
    <td valign="bottom" nowrap align="right"><font face="Verdana" size="1">&nbsp;</font></td>
  </tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
  <tr>
    <td bgcolor="#666666" height="20" align="left" valign="middle" nowrap colspan="4">&nbsp;<font color="#FFFFFF" face="Verdana, Arial, Helvetica, sans-serif" size="1"><b><a style="color: #FFFFFF; text-decoration: none" href="http://www.metalinks.com/default.htm"><img src="images/icon.gif" border="0" align="middle" WIDTH="16" HEIGHT="16"> metalinks.com</a>&nbsp;|
      <b>&nbsp;<a href="default.asp" style="color:#FFFFFF;text-decoration:none;">Home</a>&nbsp;|
      &nbsp;<a href="mailto:webmaster@metalinks.com" style="color:#FFFFFF;text-decoration:none;">Customer
      Service</a>&nbsp; |&nbsp;<a href="reviewOrder.asp" style="color:#FFFFFF;text-decoration:none;">View
      Cart</a></b> |&nbsp;<a href="search.asp" style="color:#FFFFFF;text-decoration:none;">
      Product Search</a></b></font></td>
  </tr>
</table>
<hr color="#CCCCCC" size="1" noshade>
<table border="0" bgcolor="#FFFFFF" cellpadding="0" cellspacing="0" width="700">
  <tr>
    <td width="128" valign="top" align="center">
      <table border="0" cellspacing="4" cellpadding="4" width="125">
        <tr>
          <td width="128" bgcolor="#FFFFFF"><b><font color="#ff9900" size="3" face="Arial"><i>Live
            Demo</i></font></b><br>
            <br>
            <font face="Verdana" color="#808080" size="1">This store and
            its products are for demonstration purposes only. You cannot
            actually purchase any of the products, nor is there a secure server
            to process your order.</font><br>
            <br>
            <br>
           
            <font face="Verdana" size="2" color="#808080"><a href="moreinfo.asp"><br>
            <b>More info</b><br>
            </a><a href="mailto:webmaster@metalinks.com"><b>Contact us</b></a></font><br>
          </td>
        </tr>
      </table>
    <td width="1" bgcolor="#000000"><img src="images/spacer.gif" width="1" height="1" alt border="0"></td>
    <td align="left" valign="top"><table border="0" cellspacing="4" cellpadding="4"><tr><td>
    <p><font face="Verdana" size="4"><strong>Your Order</strong></font></p>
            <p><font face="Verdana" size="2">Is something incorrect? Feel free to
            <a href="reviewOrder.asp"><b>change your order</b></a>.</font></p>
            <p>
            <form action="validateOrder.asp" method="post" name="form">
            <input type="hidden" name="intOrderID" value="<%=intOrderID%>">
            <table border="1" cellpadding="3" cellspacing="3" width="100%">
            <tr bgcolor="#ff9900">
                <td width="15%" align="left" valign="middle" nowrap><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Quantity<strong></font></td>
                <td width="15%" align="left" valign="middle" nowrap><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Prod. #<strong></font></td>
                <td width="40%" align="left" valign="middle"><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Description<strong></font></td>
                <td width="15%" align="left" valign="middle" nowrap><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Unit Price<strong></font></td>
                <td width="15%" align="left" valign="middle" nowrap><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Ext. Price<strong></font></td>
            </tr>
<%
            set rsProdInfo = Server.CreateObject("ADODB.Recordset")
            rsProdInfo.Open "products", Conn, adOpenStatic, adLockOptimistic, adCmdTable

            intTotal = 0

            rsProd.MoveFirst
            while not rsProd.EOF
                rsProdInfo.MoveFirst
                rsProdInfo.Find "productID = " & rsProd("productID")
                intProdID = rsProd("productID")
                strProdName = rsProdInfo("productName")
                intPrice = formatNumber(rsProdInfo("productPrice"), 2)
                intQuant = rsProd("quantity")
                intExtPrice = formatNumber((intPrice * intQuant), 2)
                intTotal = intTotal + intExtPrice
%>
                <tr>
                    <td width="15%" align="left" valign="middle" nowrap><font face="Verdana" size="2"><%= intQuant %></font></td>
                    <td width="15%" align="left" valign="middle" nowrap><font face="Verdana" size="2"><%= intProdID %></font></td>
                    <td width="40%" align="left" valign="middle" nowrap><font face="Verdana" size="2"><%= strProdName %></font></td>
                    <td width="15%" align="right" valign="middle" nowrap><font face="Verdana" size="2">$<%= intPrice %></font></td>
                    <td width="15%" align="right" valign="middle" nowrap><font face="Verdana" size="2">$<%= intExtPrice %></font></td>
                </tr>
                <input type="hidden" name="strOrderItem" value="<%= intProdID %>,<%= intQuant %>">
<%
                rsProd.MoveNext
            wend                       
%>
<%
            'display total for products in cart
%>                       
            <tr>
                <td colspan="4" align="left" valign="middle" nowrap><font face="Verdana" size="2">Subtotal:</font></td>
                <td align="right" valign="middle" nowrap><font face="Verdana" size="2">
                    $<%= formatNumber(intTotal, 2) %>
                </font></td>
            </tr>
<%
            'add and display amount charged for shipping:
            'in this case it's 5% of total for products in cart
            'change the .05 to meet your requirements
%>                       
            <tr>
                <td colspan="4" align="left" valign="middle" nowrap><font face="Verdana" size="2">Shipping (5%):</font></td>
                <td align="right" valign="middle" nowrap><font face="Verdana" size="2">
                    $<%= formatNumber((intTotal * .05), 2) %>
                    <input type="hidden" name="intShipping" value="<%= formatNumber((intTotal * .05), 2) %>">
                </font></td>
            </tr>
<%
            'add and display amount charged for sales tax:
            'in this case it's 8% of total for products in cart
            'change the .08 to meet your state/province requirements
%>                         
            <tr>
                <td colspan="4" align="left" valign="middle" nowrap><font face="Verdana" size="2">Tax (8%):</font></td>
                <td align="right" valign="middle" nowrap><font face="Verdana" size="2">
                    $<%= formatNumber((intTotal * .08), 2) %>
                    <input type="hidden" name="intTax" value="<%= formatNumber((intTotal * .08), 2) %>">
                </font></td>
            </tr>
<%
            'display Grand Total: to get the multiplier 1.0 is the product(s) total plus .08
            'for sales tax and .05 for shipping which equals 1.13. Be sure to change this
            'to meet your requirements
%>             
            <tr>
                <td colspan="4" align="left" valign="middle" nowrap><font face="Verdana" size="2"><b>Total:</b></font></td>
                <td align="right" valign="middle" nowrap><font face="Verdana" size="2"><b>
                    $<%= formatNumber((intTotal*1.13), 2) %>
                    <input type="hidden" name="intTotal" value="<%= formatNumber((intTotal * 1.13), 2) %>">
                </b></font></td>
            </tr>
            </table>       
            <p><font face="Verdana" size="4"><strong>Payment/Shipping Information</strong></font></p>
            <table width="100%">
            <tr>
                <td bgcolor="#ff9900" colspan="2"><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Customer Information</strong></font></td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Name(First, Last): </font></td>
                <td>
                <input type="text" name="strFirst" size="10">
                <input type="text" name="strLast" size="10">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">E-mail Address: </font></td>
                <td>
                <input type="text" name="strEmail" size="21"><font face="Verdana" size="1">&nbsp;Example: user@metalinks.com</font>
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Street Address: </font></td>
                <td>
                <input type="text" name="strAddress1" size="21">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">P.O. Box/Rural Route: </font></td>
                <td>
                <input type="text" name="strAddress2" size="21"><font face="Verdana" size="1">&nbsp;Enter &quot;NA&quot; if not applicable</font>
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">City, State, Postal Code: </font></td>
                <td>
                <input type="text" name="strCity" size="10">
                <input type="text" name="strState" size="5">
                <input type="text" name="strPostalCode" size="5">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Country: </td>
                <td>
                <input type="text" name="strCountry" size="21">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Telephone: </font></td>
                <td>
                <input type="text" name="strPhone" size="21"><font face="Verdana" size="1">&nbsp;Example: 512-555-5555</font>
                </td>
            </tr>
            <tr>
            <td colspan="2"><hr color="#CCCCCC" size="1" noshade></td>
            </tr>
            <tr>
                <td bgcolor="#ff9900" colspan="2"><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Shipping Information (if different than Customer Information)</strong></font></td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Name(First, Last): </font></td>
                <td>
                <input type="text" name="strShipFirst" size="10">
                <input type="text" name="strShipLast" size="10">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Address: </font></td>
                <td>
                <input type="text" name="strShipAddress" size="21">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">City, State, Postal Code: </font></td>
                <td>
                <input type="text" name="strShipCity" size="10">
                <input type="text" name="strShipState" size="5">
                <input type="text" name="strShipPostalCode" size="5">
                </td>
            </tr>
            <tr>
                <td><font face="Verdana" size="2">Country: </td>
                <td>
                <input type="text" name="strShipCountry" size="21">
                </td>
            </tr>
            <tr>
            <td colspan="2"><hr color="#CCCCCC" size="1" noshade></td>
            </tr>
            <tr>
                <td bgcolor="#ff9900" colspan="2"><font color="#FFFFFF" face="Verdana" size="2" style="background-color: #ff9900"><strong>Shipping Method</strong></font></td>
            </tr>
            <tr>
                <td colspan="2"><font face="Verdana" size="2">
                <input type="radio" name="strShipMethod" value="UPS" CHECKED>
                United Parcel Service
                <input type="radio" name="strShipMethod" value="FedEx">
                Federal Express
                </font></td>
            </tr>
            <tr>
            <td colspan="2"><hr color="#CCCCCC" size="1" noshade></td>
            </tr>
           
            <tr>
                <td colspan="2" align="center">
                <input type="submit" value="Submit Order" id="submit1" name="submit1">
                </td>
            </tr>
            </table>           
            </form>
        </td>
  </tr>
  </table>
  </td>
  </tr>
  </table>
      <hr color="#CCCCCC" size="1" noshade>
     
<table border="0" cellpadding="0" cellspacing="6" width="100%"> 
  <tr>
    <td colspan="3" valign="BOTTOM"><font face="Verdana, Arial, Helvetica" size="1">     
     
      Last Updated: <!--webbot bot="Timestamp" s-type="EDITED" s-format="%A, %B %d, %Y" startspan -->Saturday, July 07, 2001<!--webbot bot="Timestamp" endspan i-checksum="49640" -->
      <br>
      Powered by <a href="http://metalinks.com/metacart.htm">MetaCart</a>,
      ©2000-2001 <a href="http://metalinks.com/">MetaLinks.com</a><br>
      </font></td>
  <td colspan="3" align="right" valign="TOP">&nbsp;
  </td>
  </tr>
</table>
</body>
</html>
<%       
rsProd.Close
set rsProd = Nothing

rsProdInfo.Close
set rsProdInfo = Nothing
        end if
    end if
end if

Conn.Close
set Conn = Nothing
%>

---ASP-kode slut---
Avatar billede need-help-2 Nybegynder
05. november 2003 - 20:04 #1
Lukker
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester