Hvad er der galt ?
Jeg har prøvet at rette filen til, så den passer på min maskine. Jeg ved ikke hvad der er galt, det lader til at den bare kører og kører.<%
\'Variables assigned on start of document
\'all leading and trailing blanks are removed
\'and any single quotes are changed to '
u_action=request.querystring(\"u_action\")
u_title=replace(trim(request.form(\"u_title\")),\"\'\",\"'\")
u_body=replace(trim(request.form(\"u_body\")),\"\'\",\"'\")
u_author=replace(trim(request.form(\"u_author\")),\"\'\",\"'\")
u_log=request.querystring(\"u_log\")
script_name=request.servervariables(\"script_name\")
%>
<%
\'Check to see if the user is adding an article
\'if so, then display the input form
if u_action <> \"add\" then
set DB = Server.CreateObject(\"ADODB.Connection\")
place = Request.serverVariables(\"PATH_TRANSLATED\")
For I = Len(place) To 1 Step -1
If InStr(I, place, \"\\\") Then
PathFraFilNavn = Left(place, I - 1)
Exit For
End If
Next
place = PathFraFilNavn
DB.open \"driver={Microsoft Access Driver (*.mdb)};dbq=\" & place & \"./tips/db/tips.mdb\"
\'if the user is not looking for the input field
\'then they will be interacting with the db
\'in one of three ways.
\'1. to insert a new article
\'2. to view a specific observation
\'3. to display recent headlines
\'The following select statement will adjust the
\'sql according to which action is requested
select case u_action
case \"insert\"
sql = \"insert into articles (_title,_body,_author)\"
sql = sql & \" values( \'\" & u_title & \"\' , \'\" & u_body & \"\' , \'\" & u_author & \"\' )\"
case \"display\"
sql=\"select * from articles where log = \"&u_log
case else
sql=\"select * from articles order by date desc \"
end select
Set rs = Server.CreateObject(\"ADODB.Recordset\")
rs.Open sql, DB
\'if there are no observations found then
\'redirect the user to the default view
\'exceot if the user is adding an article
if u_action <> \"insert\" then
if rs.eof then
response.redirect script_name
end if
end if
\'Start html output
%>
<html>
<head>
<title>Recent Articles</title>
<meta name=\"GENERATOR\" content=\"Microsoft FrontPage 4.0\">
<meta name=\"ProgId\" content=\"FrontPage.Editor.Document\">
</head>
<body bgcolor=\"#FFFFFF\">
<% \'Display successful addition of article to db
if u_action=\"insert\" then %>
Your Article was added.<br>
<% else
\'Display db output %>
<% do while not rs.eof and counter < 6
\' Change 6 to any number of Titles you want to display
counter=counter+1 %>
<% if u_action <> \"display\" then %>
<a href=\"<%= script_name %>?u_action=display&u_log=<%= rs(\"log\")%>\"><%= rs(\"title\") %></a> <%= rs(\"date\") %><br>
<% else %>
<b><%= rs(\"title\") %></b><br>
by <%= rs(\"author\") %>
<p>
<pre>
<%= rs(\"body\") %>
</pre>
<% end if %>
<%
rs.movenext
loop %>
<% end if
end if
%>
<% if u_action=\"add\" then
\'if the user is adding a new article
\'then display the form input fields %>
<script Language=\"JavaScript\">
<!--
function Blank_TextField_Validator(form)
{
if (form.u_title.value == \"\")
{
alert(\"Please fill in the title field.\");
form.u_title.focus();
return (false);
}
if (form.u_body.value == \"\")
{
alert(\"Please fill in the body field.\");
form.u_body.focus();
return (false);
}
if (form.u_author.value == \"\")
{
alert(\"Please fill in the author field.\");
form.u_author.focus();
return (false);
}
return (true);
}
//-->
</script>
<form method=\"post\" action=\"<%= script_name %>?u_action=insert\" onsubmit=\"return Blank_TextField_Validator(this)\">
Title<br>
<input type=\"text\" name=\"u_title\" size=\"65\">
<p>Body<br>
<textarea rows=\"8\" name=\"u_body\" cols=\"65\"></textarea>
<p>Author<br>
<input type=\"text\" name=\"u_author\" size=\"65\">
<p><input type=\"submit\" value=\"Submit\"></p>
<input type=\"hidden\" name=\"recipient\" value=\"webmaster@trippendales.dk\" size=\"20\"><input type=\"hidden\" name=\"subject\" value=\"Godkendelse af nyhed\" size=\"20\"><input type=\"hidden\" name=\"messageline1\" value=\"gå til http://www.domain.dk/nyhed/admin.asp?id=1 for at godkende\" size=\"20\">
</form>
<% else
\'if the user is doind anything other than adding an article
\'display navigational hyperlinks %>
<p><a href=\"<%= script_name %>\">View Recent Articles</a><br>
<a href=\"<%= script_name %>?u_action=add\">Add Your Article</a>
<% end if %>
<% if u_action = \"insert\" Then %>
<%
Set mailer = Server.CreateObject(\"ASPMAIL.ASPMailCtrl.1\")
\'recipient = Request.Form(\"recipient\")
recipient = Request(\"recipient\")
sender = Request.Form(\"u_author\")
subject = Request.Form(\"subject\")
message = Request.Form(\"messageline1\")
message = message & vbCRLF
\' insert your mail server here
mailserver = \"mail.euroconnect.dk\"
result = mailer.SendMail(mailserver, recipient, sender, subject, message)
%>
<% If \"\" = result Then %>
<p>Din mail er nu undervejs, og din nyhed vil blive behandlet hurtigst muligt.
<% Else %>
Mailen kunne ikke sendes.
<h2>
<%= result %>
</h2>
<% End If
%>
<% end if
%>
</body>
