lille problem i simpelt shopscript
jeg har fundet et simpelt shop-script.Det er svensk - så der er lige 2 ting der skal ændres.
Der er 2 bokse til postnr. og 2 bokse til telefonnr på ordresiden. Er der nogle der kan rette det til en boks ved hver?
Tror det handler om bla. postnr2 og tfn2.
Herunder følger 2 filer..
default.asp:
<html><%
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &Server.MapPath("webshop.mdb")
Session.Lcid = 1053
%>
<!--#include file="installningar.asp" -->
<%
Function kollabild(text)
dim filesys, newfolder
set filer = CreateObject("Scripting.FileSystemObject")
mappen = Server.MapPath(mapp)
If Not filer.FolderExists(mappen) Then
filer.CreateFolder mappen
End If
filen = mapp & "/" & text & ".gif"
If Not filer.FileExists(Server.MapPath(filen)) Then
Response.Write "bilder/nopicture.gif"
Else
Response.Write "filer/" & text & ".gif"
End if
Set filer = Nothing
End Function
%>
<head>
<title>Webshop</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="#D2DCE6" text="#000000" leftmargin="" topmargin="0">
<table width="670" border="0" align="center" cellpadding="0" cellspacing="0" style="border-left: #000000 1px solid;border-right: #000000 1px solid;border-bottom: #000000 1px solid">
<tr>
<td height="82" align="left" valign="top"><img src="bilder/webshop.gif" width="670" height="82"></td>
</tr>
<tr>
<td background="bilder/meny_inbg.gif">
<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tr>
<td width="165" valign="top">
<table border="0" cellspacing="0" cellpadding="0" width="140">
<tr>
<td valign="top">
<p><b><img src="tr.gif" width="7" height="6"><font color="#000000">Val
av produkt:</font></b><br>
<br>
<%
SQL = "SELECT id, namn FROM kategorier ORDER BY namn"
Set RecSet = Connect.Execute(SQL)
IF RecSet.EOF then
Response.Write "<i>Inga kategorier inlagda...</i>"
ELSE
Do until RecSet.EOF
Response.Write "<img src='bilder/h_pil.gif' width=4 height=6>"
Response.Write " <a href='default.asp?category=" & RecSet("id") & "'>"
Response.Write RecSet("namn") & "</a><br>"
RecSet.MoveNext
Loop
END IF
RecSet.Close
Set RecSet = nothing
IF Len(Session("nyprod")) > 0 then
Response.Write "<br>" & Session("nyprod")
Session("nyprod") = ""
END IF
%></p>
</td>
</tr>
</table>
<div align="center"><br>
<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?show=kundvagn"><img src="bilder/kundvagn.gif" width="123" height="22" border="0"></a><br>
<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?show=kassa"><img src="bilder/kassan.gif" width="123" height="22" border="0"></a></div>
</td>
<td valign="top">
<%
kat = Request.Querystring("category")
IF Len(kat) > 0 then
SQL = "SELECT * FROM produkter WHERE kat =" & kat & " ORDER BY namn"
Set RecSet = Connect.Execute(SQL)
IF RecSet.EOF then
Response.Write "Inga artiklar hittades..."
ELSE
Do until RecSet.EOF
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="126" height="120" valign="top"><img src="<%=kollabild(RecSet("id"))%>" width="120" height="120"></td>
<td valign="top"><table width="100%" height="120" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<%
Response.Write "<b>Produktnamn:</b> " & RecSet("namn") & "<br>"
Response.Write "<b>Artikelnummer:</b> " & RecSet("artnr") & "<br><br>"
Response.Write "<b>Beskrivning:</b> <br>" & RecSet("beskrivning") & " "
%>
</td>
</tr>
<tr>
<td height="20" valign="bottom">
<form name="form1" method="post" action="spara.asp?id=<%=RecSet("id")%>&namn=<%=RecSet("namn")%>&pris=<%=RecSet("pris")%>">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><%
Response.Write "<b>Pris:</b> "
pris = RecSet("pris")
pris2 = FormatCurrency(pris,2)
pris2 = Replace(pris2,",00","")
Response.Write pris2
IF inklmoms = 1 then
Response.Write " Inkl. moms"
ELSE
Response.Write " Exkl. moms"
END IF
Response.Write "</td>"
%> <td> <div align="right">
<input name="antal" type="text" style="background: #A2B1C2; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px" value="1" size="3" maxlength="4">
<input type="submit" name="Submit" value="Lägg i kundvagn" style="background: #85A0B8; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</td>
</tr>
<tr colspan=2>
<td> </td>
</tr>
</table>
<%
RecSet.MoveNext
Loop
END IF
RecSet.Close
Set RecSet = Nothing
ELSEIF Request("show") = "kundvagn" then
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><strong><font size="2" face="Verdana">Din kundvagn</font></strong><br>
<span class="vit"><br>
</span>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<%
varde = Request.Cookies(""& Session.SessionID &"")
hamta = Split(varde,"&")
ReDim MyArray(4,Ubound(hamta))
for x = 0 to ubound(hamta)
hamta2 = Split(hamta(x),"=")
IF Len(hamta2(0)) > 0 AND len(hamta2(1)) > 0 then
SQL = "SELECT * FROM produkter WHERE id =" & int(hamta2(0))
Set RecSet = Connect.Execute(SQL)
MyArray(0,x) = hamta2(0)
MyArray(1,x) = hamta2(1)
MyArray(2,x) = RecSet("artnr")
MyArray(3,x) = RecSet("namn")
MyArray(4,x) = RecSet("pris")
RecSet.Close
Set RecSet = nothing
END IF
next
For i = 0 To Ubound(myArray,2)
IF Len(MyArray(0,i)) > 0 then
andra = andra & myArray(0,i) & "=" & myArray(1,i)
IF NOT i = Ubound(myArray,2) then
andra = andra & "|"
END IF
END IF
Next
Session("andra") = andra
%>
<tr>
<td width="50"><strong>Art.nr</strong></td>
<td width="120"><strong>Namn</strong></td>
<td width="55"><strong>á-pris</strong></td>
<td width="55"> <div align="center"><strong>Antal</strong></div></td>
<td width="55">
<div align="right"><strong>Totalt</strong></div></td>
<td width="65">
<div align="center"><strong>Ta bort</strong></div></td>
<td><div align="left"><strong> </strong></div></td>
</tr>
<%
count = 0
ant = 0
total = 0
For i = 0 To Ubound(myArray,2)
IF Len(MyArray(0,i)) > 0 then%>
<tr>
<form namn="minsida" action="change.asp?id=<%=MyArray(0,i)%>" method="post">
<td><%=MyArray(2,i)%></td>
<td><%=MyArray(3,i)%></td>
<td>
<%
Response.Write FormatCurrency(MyArray(4,i))%>
</td>
<td><div align="center">
<input name="antal" type="text" size="3" value="<%Response.Write MyArray(1,i)
strAntal = MyArray(1,i)
ant = ant + strAntal
%>" style="background: #A2B1C2; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px; font-color: #21283D">
</div>
</td>
<td> <div align="right">
<%
tal1 = round(MyArray(4,i),2)
tal2 = round(MyArray(1,i),2)
pris = tal1 * tal2
IF Instr(pris,",") then
pris2 = Split(pris,",")
decital = pris2(1)
IF NOT Len(decital) <> 1 then
decital = "" & decital & "0"
END IF
IF decital < 25 then
summa = pris2(0)
ELSEIF decital > 24 AND decital < 75 then
summa = pris2(0) + 0.50
ELSE
summa = pris2(0) + 1
END IF
ELSE
summa = pris
END IF
IF instr(summa2,",") then
summa2 = split(summa,",")
IF len(summa2(1)) <> 1 then
kontroll = summa & " kr"
ELSE
kontroll = summa & "0 kr"
END IF
ELSE
kontroll = summa & " kr"
END IF
Response.Write FormatCurrency(kontroll)
total = total + summa
%>
</div>
</td>
<td><div align="center"><a href="change.asp?del=ja&id=<%=myArray(0,i)%>"><img src="bilder/radera.gif" width="8" height="13" border="0"></a></div></td>
<td><div align="center"><strong>
<INPUT TYPE="image" SRC="bilder/andra.gif" VALUE="submit">
</strong></div></td>
</form>
</tr>
<%
count = count + 1
END IF
Next
IF count <> 0 then%>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td colspan="7"><div align="center">Totalt <b><%=ant%></b>
<%IF ant > 1 then
Response.Write "produkter"
ELSE
Response.Write "produkt"
END IF%>
som sammanlagt kostar <b>
<%
total2 =FormatCurrency(total)
total2 = Replace(total2," kr","")
Response.Write total2%>
</b> kronor</div></td>
</tr>
<%ELSE%>
<tr>
<td colspan="7"><em>Inga produkter i din kundvagn</em></td>
</tr>
<%END IF%>
</table>
<span class="vit"> </span></td>
</tr>
</table>
<%ELSEIF Request("show") = "kassa" then %>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><font size="2" face="Verdana"><strong>Kassan</strong></font><br>
<span class="vit"><br>
</span> <table width="90%%" border="0" cellpadding="0" cellspacing="0">
<%
varde = Request.Cookies(""& Session.SessionID &"")
hamta = Split(varde,"&")
ReDim MyArray(4,Ubound(hamta))
for x = 0 to ubound(hamta)
hamta2 = Split(hamta(x),"=")
IF Len(hamta2(0)) > 0 AND len(hamta2(1)) > 0 then
SQL = "SELECT * FROM produkter WHERE id =" & int(hamta2(0))
Set RecSet = Connect.Execute(SQL)
MyArray(0,x) = hamta2(0)
MyArray(1,x) = hamta2(1)
MyArray(2,x) = RecSet("artnr")
MyArray(3,x) = RecSet("namn")
MyArray(4,x) = RecSet("pris")
RecSet.Close
Set RecSet = nothing
END IF
next
For i = 0 To Ubound(myArray,2)
IF Len(MyArray(0,i)) > 0 then
andra = andra & myArray(0,i) & "=" & myArray(1,i)
IF NOT i = Ubound(myArray,2) then
andra = andra & "|"
END IF
END IF
Next
Session("andra") = andra
%>
<tr>
<td width="55"><strong>Art.nr</strong></td>
<td width="160"><strong>Namn</strong></td>
<td width="65"><strong>á-pris</strong></td>
<td width="60"> <div align="center"><strong>Antal</strong></div></td>
<td> <div align="right"><strong>Totalt</strong></div></td>
</tr>
<%
count = 0
ant = 0
total = 0
For i = 0 To Ubound(myArray,2)
IF Len(MyArray(0,i)) > 0 then%>
<tr>
<td><%=MyArray(2,i)%></td>
<td><%=MyArray(3,i)%></td>
<td>
<%
Response.Write FormatCurrency(MyArray(4,i))%>
</td>
<td><div align="center">
<%
Response.Write MyArray(1,i)
strAntal = MyArray(1,i)
ant = ant + strAntal
%>
</div></td>
<td> <div align="right">
<%
tal1 = round(MyArray(4,i),2)
tal2 = round(MyArray(1,i),2)
pris = tal1 * tal2
IF Instr(pris,",") then
pris2 = Split(pris,",")
decital = pris2(1)
IF NOT Len(decital) <> 1 then
decital = "" & decital & "0"
END IF
IF decital < 25 then
summa = pris2(0)
ELSEIF decital > 24 AND decital < 75 then
summa = pris2(0) + 0.50
ELSE
summa = pris2(0) + 1
END IF
ELSE
summa = pris
END IF
IF instr(summa2,",") then
summa2 = split(summa,",")
IF len(summa2(1)) <> 1 then
kontroll = summa & " kr"
ELSE
kontroll = summa & "0 kr"
END IF
ELSE
kontroll = summa & " kr"
END IF
Response.Write FormatCurrency(kontroll)
total = total + summa
%>
</div></td>
</tr>
<%
count = count + 1
END IF
Next
IF count <> 0 then%>
<tr>
<td colspan="5"> </td>
</tr>
<tr>
<td colspan="5"> <div align="right">
<table width="110" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="50">Summa:</td>
<td width="60" align="right"> <div align="right">
<% Response.Write Rtrim(FormatCurrency(total))
total2 = total %>
</div></td>
</tr>
<tr>
<td width="50">Moms:</td>
<td width="60" align="right"> <div align="right">
<%
IF inklmoms = 0 then
pris = Round(total/4,2)
IF Instr(pris,",") then
pris2 = Split(pris,",")
If len(pris2(1)) > 2 then
decital = left(pris2(1),2)
ELSE
decital = pris2(1)
END IF
IF NOT Len(decital) <> 1 then
decital = "" & decital & "0"
END IF
IF decital < 25 then
summa = pris2(0)
ELSEIF decital > 24 AND decital < 75 then
summa = pris2(0) + 0.50
ELSE
summa = pris2(0) + 1
END IF
ELSE
summa = pris
END IF
IF instr(summa,",") then
summa2 = split(summa,",")
IF len(summa2(1)) = 1 then
mkontroll = "" & summa & "0"
ELSE
mkontroll = "" & summa & ""
END IF
ELSE
mkontroll = "" & summa & ""
END IF
Response.Write mkontroll & " kr"
ELSE
Response.Write "<i>Ingår</i>"
END IF
%>
</div></td>
</tr>
<tr>
<td width="50">Frakt:</td>
<td width="60" align="right"> <div align="right">
<%Response.Write FormatCurrency(frakt)%>
</div></td>
</tr>
<tr>
<td width="50">Totalt:</td>
<td width="60" align="right"> <div align="right">
<%abtotalen = total2 + mkontroll + frakt
Response.Write FormatCurrency(abtotalen)%>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="5"><form action="order.asp" method="post">
<table width="" border="0" cellpadding="0" cellspacing="1">
<tr>
<td height="15" colspan="2"><strong>Beställningsinfo</strong></td>
</tr>
<%
IF len(Session("webshopfel")) > 0 then
falt = Split(Session("falt"),"|")
fel = 1
ELSE
fel = 0
END IF
%>
<tr>
<td>Ditt namn:</td>
<td><%
Response.Write "<input name='namn' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=30"
IF fel > 0 then
Response.Write " value='" & falt(0) & "'>"
ELSE
Response.Write ">"
END IF
%></td></tr>
<tr>
<td>Gatuadress:</td>
<td><%
Response.Write "<input name='adress' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=30"
IF fel > 0 then
Response.Write " value='" & falt(1) & "'>"
ELSE
Response.Write ">"
END IF
%></td>
</tr>
<tr>
<td>Postnr:</td>
<td>
<%
Response.Write "<input name='postnr1' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=3 maxlength=3"
IF fel > 0 then
Response.Write " value='" & falt(2) & "'>"
ELSE
Response.Write ">"
END IF
%>
<%
Response.Write " <input name='postnr2' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=2 maxlength=2"
IF fel > 0 then
Response.Write " value='" & falt(3) & "'>"
ELSE
Response.Write ">"
END IF
%>
</td>
</tr>
<tr>
<td>Postadress:</td>
<td><%
Response.Write "<input name='postadress' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=30"
IF fel > 0 then
Response.Write " value='" & falt(4) & "'>"
ELSE
Response.Write ">"
END IF
%></td>
</tr>
<tr>
<td>Telefonnr:</td>
<td><%
Response.Write "<input name='tfn1' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=5"
IF fel > 0 then
Response.Write " value='" & falt(5) & "'>"
ELSE
Response.Write ">"
END IF
Response.Write " - "
Response.Write "<input name='tfn2' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=10"
IF fel > 0 then
Response.Write " value='" & falt(6) & "'>"
ELSE
Response.Write ">"
END IF
%></td>
</tr>
<tr>
<td height="20">E-post adress:</td>
<td><%
Response.Write "<input name='epost' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=30"
IF fel > 0 then
Response.Write " value='" & falt(7) & "'>"
ELSE
Response.Write ">"
END IF%></td>
</tr>
<tr>
<td>Övrig info:</td>
<td><%
Response.Write "<input name='ovrigt' type=text style='background: #A2B1C2; border: #85A0B8 1px solid;"
Response.Write " font-family: verdana; font-size: 10px; font-color: #21283D' size=30"
IF fel > 0 then
Response.Write " value='" & falt(8) & "'>"
ELSE
Response.Write ">"
END IF%></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit2" value="Skicka beställning >>" style="background: #85A0B8; border: #85A0B8 1px solid; font-family: verdana; font-size: 10px"></td>
</tr>
<%IF Len(Session("webshopfel")) > 0 then%>
<tr>
<td colspan="2"><%=Session("webshopfel")%></td>
</tr>
<%Session("webshopfel") = ""
ELSEIF Len(Request("skickad")) > 0 then%>
<tr><td><%Response.Write "Nu är din beställning skickad!"%></td></tr><%END IF%>
</table>
</form></td>
</tr>
<%ELSE%>
<%IF Request("skickad") = "ja" then %>
<tr><td colspan="5"><em>Din beställning är nu skickad</em></td></tr><%ELSE%>
<tr>
<td colspan="5"><em>Inga produkter i din kundvagn</em></td>
</tr>
<%END IF
END IF%>
</table></td>
</tr>
</table>
<%ELSE%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top"><font size="2" face="Verdana"><strong>Välkommen
till min webshop!</strong></font><br>
<br>
Denna webshop är kodad av Joakim på <a href="http://www.joakimweb.com" target="_blank">joakimweb.com</a>
och designad av Mathias på <a href="http://www.ebtrox.net" target="_blank">ebtrox.net</a>.
Får användas fritt sålänge copyright-koden
förblir intakt. Lycka till med din webbutik!</td>
</tr>
</table>
<%END IF%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<table width="675" border="0" align="center">
<tr>
<td><div align="center">Design by <a href="http://www.ebtrox.net" target="_blank">Ebtrox.net</a>
| Code by <a href="http://www.joakimweb.com" target="_blank">JoakimWeb.com</a></div></td>
</tr>
</table>
</body>
</html>
Order.asp:
<!--#include file="installningar.asp"-->
<%
Response.Buffer = true
namn = Request.Form("namn")
adress = Request.Form("adress")
postnr1 = Request.Form("postnr1")
postnr2 = Request.Form("postnr2")
padress = Request.Form("postadress")
tfn1 = Request.Form("tfn1")
tfn2 = Request.Form("tfn2")
epost = Request.Form("epost")
ovrigt = Request.Form("ovrigt")
info = Array(namn,adress,postnr1,postnr2,padress,tfn1,tfn2,epost,ovrigt)
info2 = ""
For i = 0 to 8
info2 = info2 & info(i)
IF Not i = 8 then
info2 = info2 & "|"
END IF
Next
For i = 0 to 7
IF NOT len(info(i)) <> 0 then
Session("webshopfel") = "Du glömde att fylla i något fält"
session("falt") = info2
Response.Redirect Request.ServerVariables("HTTP_REFERER")
END IF
Next
IF len(info(2)) > 5 then
Session("webshopfel") = "Felaktigt postnummer"
Session("falt") = info2
Response.Redirect Request.ServerVariables("HTTP_REFERER")
END IF
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" &Server.MapPath("webshop.mdb")
Session.Lcid = 1053
varde = Request.Cookies(""& Session.SessionID &"")
hamta = Split(varde,"&")
ReDim MyArray(4,Ubound(hamta))
for x = 0 to ubound(hamta)
hamta2 = Split(hamta(x),"=")
IF Len(hamta2(0)) > 0 AND len(hamta2(1)) > 0 then
SQL = "SELECT * FROM produkter WHERE id =" & int(hamta2(0))
Set RecSet = Connect.Execute(SQL)
MyArray(0,x) = hamta2(0)
MyArray(1,x) = hamta2(1)
MyArray(2,x) = RecSet("artnr")
MyArray(3,x) = RecSet("namn")
MyArray(4,x) = RecSet("pris")
RecSet.Close
Set RecSet = nothing
END IF
next
Set jmail = Server.CreateObject("JMail.Message")
jmail.AddRecipient ""& eposten &"", ""& eposten &""
jmail.From = "" & info(7) & ""
jmail.Subject = "Beställning"
jmail.appendHTML "<font face=verdana size=1>"
For i = 0 To Ubound(myArray,2)
IF Len(MyArray(0,i)) > 0 then
jmail.appendHTML "<b>Art.nr: </b>" & MyArray(2,i) & "<br>"
jmail.AppendHTML "<b>Produkt: </b>" & MyArray(3,i) & "<br>"
jmail.AppendHTML "<b>Antal: </b>" & MyArray(1,i) & "<br>"
jmail.AppendHTML "-------------------------------------------<br>"
IF i = Ubound(myArray,2) then
jmail.AppendHTML " <br>"
END IF
END IF
Next
jmail.appendHTML "<b>Namn: </b>" & info(0) & "<br>"
jmail.appendHTML "<b>Adress: </b>" & info(1) & "<br>"
jmail.appendHTML "<b>Postnr: </b>" & info(2) & info(3) & "<br>"
jmail.appendHTML "<b>Postadress: </b>" & info(4) & "<br>"
jmail.appendHTML "<b>Telefonnummer: </b>" & info(5) & "-" & info(6) & "<br>"
jmail.appendHTML "<b>E-post: </b>" & info(7) & "<br>"
jmail.appendHTML "<b>Övrigt: </b>" & info(8) & "<br>"
jmail.appendHTML "<b>Skickat: </b>" & Now() & "<br>"
jmail.appendHTML "</font>"
jmail.Send(mailserver)
For Each nyckel in Request.Cookies(Session.SessionID)
Response.Cookies(Session.SessionID)(nyckel) = ""
Next
sida = Request.ServerVariables("HTTP_REFERER") & "&skickad=ja"
Response.Redirect sida
%>
Håber i kan hjælpe...