<% on error resume next 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") %> <% if u_action <> "add" then 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 accessdb="articles" cn="driver={Microsoft Access Driver (*.mdb)};" cn= "Data Source=" & Server.Mappath("db/noticias.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;" 'cn=cn & "dbq=" & server.mappath(accessdb) Set rs = Server.CreateObject("ADODB.Recordset") rs.Open sql, cn '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 %> Jornal
asd
:: seções
Notícia do dia
Esta semana
Temperos da Tia Anastácia
Meninos EU VI...
Entrevista da semana
Circulando
Ya San Levy
Lição de Mestre
Ventilador
Dizem por aí
Esporte
Arquivo
Fale conosco

<% 'Display successful addition of article to db if u_action="insert" then %>
<% else 'Display db output %> <% do while not rs.eof and counter < 15 ' Change 6 to any number of Titles you want to display counter=counter+1 %> <% if u_action <> "display" then %> "><%= rs("title") %> <%= rs("date") %>
<%= RS("TRECHO") %>

<% else %>

<%= rs("title") %>
Por:<%= rs("author") %>

<%= rs("body") %>

 Ver mais notícias<% 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  %>
                          
                          <% else
'if the user is doind anything other than adding an article
'display navigational hyperlinks %>
                           
                          <% end if %>