Jan vorrei che ci fosse anche l'ora d'immissione a fianco di ogo news oltre che alla data.
e' possibile??
posto il codice per chi non lo conoscesse
P.S. COME VEDI HO GIA' INSERITO IL REFRESH AUTOMATICO
code:
<% Response.Buffer = True %>
<link rel="stylesheet" href="style.css" type="text/css">
<body onload="setTimeout('location.reload()',20000)" bgcolor="#C0C0C0">
<div align="center">
<% If Request.QueryString("act") = "ShowNews" OR Request.QueryString("act") = "" Then %>
<table cellspacing="1" cellpadding="0" width="430" bgcolor="#0099FF" border="0" height="12">
<tr>
<td bgcolor="#FFFFFF" height="18">
<table cellspacing="1" cellpadding="1" width="406" bgcolor="#FFFFFF" border="0" height="1">
</table>
<table cellspacing="1" cellpadding="1" width="430" bgcolor="#FFFFFF" border="0" height="8">
<td bgcolor="#FFFFFF" height="2" colspan="2">
<table cellspacing="1" cellpadding="1" width="430" bgcolor="#FFFFFF" border="0" height="8">
<tr>
<td bgcolor="#FFFFFF" height="2">
<!-- #INCLUDE file="adovbs.inc" -->
<%
Dim iPageSize
Dim iPageCount
Dim iPageCurrent
Dim RS2
Dim iRecordsShown
iPageSize = 5
If Request.QueryString("PageNews") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("PageNews"))
End If
Dim Conn2
Set Conn2 = Server.CreateObject("ADODB.Connection")
conn2.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & server.mappath("mdb-database/news.mdb")
Set rs2 = Server.CreateObject("ADODB.Recordset")
sql2 = "SELECT * FROM news ORDER BY id DESC"
RS2.Open sql2, conn2, adOpenKeyset
RS2.PageSize = iPageSize
RS2.CacheSize = iPageSize
iPageCount = RS2.PageCount
Dim totale
totale = rs2.recordcount
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1
If iPageCount = 0 Then
Response.Redirect("default.asp")
Else
RS2.AbsolutePage = iPageCurrent
%>
<table align="center" width="417" cellpadding="0" cellspacing="0" height="19">
<%
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not RS2.EOF
%>
<tr>
<td width="10">
<li>
</td>
<td width="398"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#000099"><b><%= rs2("data")%></b></font>
<font face="Verdana, Arial, Helvetica, sans-serif" size="1">-
<%= rs2("messaggio")%></font></td>
</tr>
<%
iRecordsShown = iRecordsShown + 1
RS2.MoveNext
Loop
End If
RS2.Close
Set RS2 = Nothing
Conn2.Close
Set Conn2= Nothing
%>
</table>
<table align="center" width="404" cellpadding="0" cellspacing="0" height="19">
<tr>
<td width="50%"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<%
If iPageCurrent <> 1 Then
%>
<a href="news.asp?act=ShowNews&PageNews=<%= iPageCurrent - 1 %>">«
Precedente</a>
<% End If %>
</font></td>
<td width="50%" align="right"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">
<%
If iPageCurrent < iPageCount Then
%>
<a href="news.asp?act=ShowNews&PageNews=<%= iPageCurrent + 1 %>">Successivo
» </a>
<% End If %>
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
If Session("sicuro") <> "si" Then
Response.Write "<br><a href=""news.asp?act=ShowForm""><font size=""1"" face=""Verdana, Arial, Helvetica, sans-serif"">Aggiungi una news.</font></a><br>"
Else
Response.Write "<br><a href=""news.asp?act=Logout""><font size=""1"" face=""Verdana, Arial, Helvetica, sans-serif"">Logout.</font></a><br>"
End If
%>
<% End If %>
<%
If Request.QueryString("act") = "ShowForm" Then
If Session("sicuro") <> "si" Then Response.Redirect "news.asp?act=Login"
Response.Write " <table align=""center"" cellpadding=""1"" cellspacing=""0"" width=""430"" bgcolor=""#0099FF"">" &_
" <tr> " &_
" <td colspan=""2"" align=""right"" bgcolor=""#FFFFFF"">" &_
" <table align=""center"" width=""430"" cellpadding=""0"" cellspacing=""2"" height=""19"">" &_
" <form method=""post"" action=""news.asp?act=PostNews"">" &_
" <tr> " &_
" <td>" &_
" <div align=""center""><b><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"">Messaggio</font></b></div>" &_
" </td>" &_
" </tr>" &_
" <tr> " &_
" <td> " &_
" <div align=""center"">" &_
" <textarea name=""messaggio"" rows=""5"" cols=""30""></textarea>" &_
" </div>" &_
" </td>" &_
" </tr>" &_
" <tr> " &_
" <td> " &_
" <div align=""center"">" &_
" <input type=""submit"" value="" Posta "" name=""submit"">" &_
" <input type=""reset"" value="" Cancella "" name=""reset"">" &_
" </div>" &_
" </td>" &_
" </tr>" &_
" </form>" &_
" </table>" &_
" </td>" &_
" </tr>" &_
" </table>"
Response.End
End If
%>
<%
If Request.QueryString("act") = "PostNews" Then
If Session("sicuro") <> "si" Then Response.Redirect "news.asp?act=Login"
Dim messaggio
Dim data
messaggio=Request.Form("messaggio")
data=DateSerial(Year(Now),Month(Now),Day(Now))
If messaggio="" Then
Response.Write"<font face=""verdana"" size=""1"">Inserire un messaggio<br><a href=""javascript:history.back(-1)"">Indietro!</a></font>"
Response.End
End If
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & server.MapPath("mdb-database/news.mdb")
Sql = "SELECT * FROM news"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, 3, 3
RS.AddNew
rs.Fields("messaggio")=messaggio
rs.Fields("data")=data
rs.update
RS.Close
Set RS=Nothing
conn.Close
Set conn=Nothing
response.redirect("news.asp?act=ShowNews")
End If
%>
<%If Request.QueryString("act") = "Logout" Then
Session.Abandon()
Response.Redirect "news.asp?act=ShowNews"
Response.End
End If
%>
<%If Request.QueryString("act") = "Login" Then
Dim username
username=Request.Form("username")
Dim pass
pass=Request.Form("password")
user = Replace(Request.Form("username"),"'","''")
pwd = Replace(Request.Form("password"),"'","''")
If user="prova" AND pwd="prova" Then
Session("sicuro")="si"
Session.Timeout=20
Response.Redirect("news.asp?act=ShowForm")
Response.End
Else
Response.Write "<font face=""Verdana"" size=""2"" color=""red"">Errore: Username o Password errati !</font><br><br>" &_
" <table align=""center"" cellpadding=""1"" cellspacing=""0"" width=""430"" bgcolor=""#0099FF"">" &_
" <tr> " &_
" <td colspan=""2"" align=""right"" bgcolor=""#FFFFFF"">" &_
" <table align=""center"" width=""430"" cellpadding=""0"" cellspacing=""2"" height=""19"">" &_
" <form method=""post"" action=""news.asp?act=Login"">" &_
" <tr> " &_
" <td>" &_
" <div align=""center""><b><font face=""Verdana, Arial, Helvetica, sans-serif"" size=""2"">Login</font></b></div>" &_
" </td>" &_
" </tr>" &_
" <tr> " &_
" <td> " &_
" <div align=""center"">" &_
" <font face=""Verdana, Arial, Helvetica, sans-serif"" size=""1"">Username:</font><br><input type=""text"" name=""username""><br>" &_
" <font face=""Verdana, Arial, Helvetica, sans-serif"" size=""1"">Password:</font><br><input type=""text"" name=""password""><br>" &_
" <input type=""submit"" value="" Login "">" &_
" </div>" &_
" </td>" &_
" </tr>" &_
" </form>" &_
" </table>" &_
" </td>" &_
" </tr>" &_
" </table>"
Response.End
End If
%>
<% End If %>
</div>