Jeg har ikke ændret ret meget i det grundlæggende script. Det er jo heller ikke der problemet ligger. Det fungerer upåklageligt indtil, at jeg prøver at lægge et upload script på.
Det jeg har lagt på her er uden komponent.
Jeg vil smutte ind og sove. ZZZnakkes vi ved imorgen? :-)
<%@ language="vbscript" codepage="1252" %>
<link rel="stylesheet" type="text/css" href="style.css">
<!-- #INCLUDE FILE="fileupload.inc" -->
<%
If Request.ServerVariables("REQUEST_METHOD") <> "POST" Then
%>
<%
Else
Dim intFileUpload, strContentType, strFilename, intFileTotalBytes
intFileUpload = FileUpload("upload/", 20000, Array("image/gif", "image/jpeg", "image/pjpeg"), Array("gif", "jpg"), strContentType, strFilename, intFileTotalBytes)
If intFileUpload = 0 Then
Response.Write "Filen " & strFilename & " blev uploaded.<BR>"
Response.Write "Det er en fil af typen " & strContentType & " og den fylder " & intFileTotalBytes & " bytes:<BR>"
Response.Write "<IMG SRC=""upload/" & strFilename & """><BR>"
Else
Response.Write "Der opstod en fejl under upload!<BR>"
Response.Write "Fejl nr: " & intFileUpload & "<BR>"
Response.Write "Filnavn: " & strFilename & "<BR>"
Response.Write "Filtype: " & strContentType & "<BR>"
Response.Write "Filstørrelse: " & intFileTotalBytes & "<BR>"
End If
End If
%>
<%
if cstr(Request.QueryString("mode")) = "new" then
Session.Contents("userid") = 0
else
if IsEmpty(Session.Contents("userid")) OR cstr(Session.Contents("userid") & "") = "" then
Server.Transfer "login.asp"
end if
end if
Server.Execute "setupConn.asp"
strConn = Session.Contents("ConnectionString")
set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConn
if cstr(Request.Form("Opdater")) <> "" then
SQLBeskrivelse = Replace(Request.Form("Beskrivelse"),"'","''")
if len(SQLBeskrivelse) > 255 then
SQLBeskrivelse = left(SQLBeskrivelse, 255)
end if
if Session.Contents("userid") > 0 then
strSQL = "UPDATE bruger SET"
strSQL = strSQL & " Navn='" & Replace(Request.Form("Navn"),"'","''") & "'"
strSQL = strSQL & ", [Password]='" & Replace(Request.Form("Password"),"'","''") & "'"
strSQL = strSQL & ", Email='" & Replace(Request.Form("Email"),"'","''") & "'"
strSQL = strSQL & ", Adresse='" & Replace(Request.Form("Adresse"),"'","''") & "'"
strSQL = strSQL & ", Bynavn='" & Replace(Request.Form("Bynavn"),"'","''") & "'"
strSQL = strSQL & ", fileupload='" & Replace(Request.Form("fileupload"),"'","''") & "'"
strSQL = strSQL & ", Kategori='" & Request.Form("Kategori") & "'"
strSQL = strSQL & ", Beskrivelse='" & SQLBeskrivelse & "'"
strSQL = strSQL & " WHERE ID=" & Session.Contents("userid")
objConn.Execute strSQL
else
strSQL = "INSERT INTO bruger"
strSQL = strSQL & "(Navn,[Password],Email,Adresse,Bynavn,fileupload,Kategori,Beskrivelse,OprettetDato) "
strSQL = strSQL & "VALUES("
strSQL = strSQL & "'" & Replace(Request.Form("Navn"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(Request.Form("Password"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(Request.Form("Email"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(Request.Form("Adresse"),"'","''") & "'"
strSQL = strSQL & ",'" & Replace(Request.Form("Bynavn"),"'","''") &"'"
strSQL = strSQL & ",'" & Replace(Request.Form("fileupload"),"'","''") &"'"
strSQL = strSQL & ",'" & Request.Form("Kategori") & "'"
strSQL = strSQL & ",'" & SQLBeskrivelse & "'"
strSQL = strSQL & ",#" & now & "#"
strSQL = strSQL & ")"
objConn.Execute strSQL
set objRs = objConn.Execute("SELECT @@IDENTITY AS newId")
if not objRs.EOF then
Session.Contents("userid") = cstr(objRs("newId"))
end if
objRs.Close
set objRs = nothing
end if
objConn.Close
set objConn = nothing
Response.Redirect "forside.asp"
end if
if cstr(Request.Form("Slet")) <> "" then
strSQL = "DELETE FROM bruger WHERE ID=" & Session.Contents("userid")
objConn.Execute strSQL
objConn.Close
set objConn = nothing
Session.Contents("userid") = Empty
Response.Redirect "forside.asp"
end if
if cstr(Request.Form("Logaf")) <> "" then
objConn.Close
set objConn = nothing
Session.Contents("userid") = Empty
Response.Redirect "forside.asp"
end if
if Session.Contents("userid") > 0 then
SaveButton = "Update"
strSQL = "SELECT * FROM bruger WHERE ID = " & Session.Contents("userid")
set objRs = objConn.Execute(strSQL)
if not objRs.EOF then
Navn = cstr(objRs("Navn") & "")
Password = cstr(objRs("Password") & "")
Email = cstr(objRs("Email") & "")
Adresse = cstr(objRs("Adresse") & "")
Bynavn = cstr(objRs("Bynavn") & "")
fileupload = cstr(objRs("fileupload") & "")
Kategori = cstr(objRs("Kategori") & "")
Beskrivelse = cstr(objRs("Beskrivelse") & "")
end if
objRs.close
objConn.Close
set objRs = nothing
set objConn = nothing
else
SaveButton = "Submit"
end if
strKategorier = "[Vælg kategori],,Kategori 1,Kategori 1,Kategori 2,kategori 3,kategori 3,kategori 4,kategori4 "
arrKategorier = Split(strKategorier, ",")
Kategorier = vbCrLf
for idx = 0 to ((ubound(arrKategorier) + 1) / 2) - 1
strKategoriText = arrKategorier(idx * 2)
strKategoriValue = arrKategorier(idx * 2 + 1)
Kategorier = Kategorier & "<option value=""" & strKategoriValue & """"
if strKategoriValue = Kategori then
Kategorier = Kategorier & " SELECTED"
end if
Kategorier = Kategorier & ">" & strKategoriText & vbCrLf
next
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd"> <html>
<style type="text/css">
<!--
.style5 {
font-size: 24px;
font-weight: bold;
}
-->
</style>
<head>
<title>Vedligehold brugeroplysninger</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.label { float:left; width:120px; }
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #06275B;
}
a {
font-size: 12px;
color: #06275B;
}
a:link {
text-decoration: underline;
}
a:visited {
text-decoration: underline;
color: #06275B;
}
a:hover {
text-decoration: none;
color: #99CCFF;
}
a:active {
text-decoration: underline;
color: #06275B;
}
.style2 {font-family: Arial, Helvetica, sans-serif}
.style4 {float: left; width: 120px; font-weight: bold; }
</style>
</head>
<body>
<form action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post" enctype="multipart/form-data">
<table width="50%" border="0">
<tr>
<td align="left" valign="top" nowrap><div align="left"><span class="style2"><span class="style3"><span class="style5"><font face="Arial Black, Impact, MS Sans Serif">GTO
Recycle</font></span><img src="../mimages/cycle10.gif" width="70" height="77"></span></span></div></td>
</tr>
</table>
<table width="57%" border="1" bordercolor="#99CCFF">
<tr>
<td width="11%" valign="top" bordercolor="#FFFFFF"><span class="style4">Navn:</span></td>
<td width="89%" colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength="255" name="Navn" value="<%=Navn%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Password:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="password" maxlength=50" name="Password" value="<%=Password%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Email:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength=255" name="Email" value="<%=Email%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Adresse:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength="255" name="Adresse" value="<%=Adresse%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Bynavn:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><input type="text" maxlength="50" name="Bynavn" value="<%=Bynavn%>"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Kategori:</span></td>
<td bordercolor="#FFFFFF"><select name="Kategori" class="style2">
<%=Kategorier%> </select></td>
<td bordercolor="#FFFFFF"><INPUT NAME="fileupload" TYPE="file"></td>
</tr>
<tr>
<td valign="top" bordercolor="#FFFFFF"><span class="style4">Beskrivelse:</span></td>
<td colspan="2" bordercolor="#FFFFFF"><textarea name="Beskrivelse" cols="50" rows="5"><%=Beskrivelse%></textarea></td>
</tr>
<tr>
<td bordercolor="#FFFFFF"> </td>
<td colspan="2" bordercolor="#FFFFFF"><input name="Opdater" type="submit" class="style4" value="<%=SaveButton%>">
<input name="Slet" type="submit" class="style4" value="Delete"> <input name="Logaf" type="submit" class="style4" value="Logoff"></td>
</tr>
</table>
<p><br>
<span class="label"> </span> <br>
<br>
</p>
</form>
</body>
</html>