Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Germa

guestbook

Recommended Posts

<%

' Variáveis de execução do banco de dados
Dim Conn
Dim RS
Dim RS2
Dim SQLStmt

' Variáveis relacionadas aos dados do visitante
Dim txt_nome_vis
Dim txt_email_vis
Dim txt_mensagem_vis
Dim OK	 
		  
	 Set Conn = Server.CreateObject("ADODB.Connection")
	 Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("guestbook.mdb")
	 Set RS = Server.CreateObject("ADODB.Recordset") 
	 OK = 1 ' OK é para controle de validação vai-se então validar o e-mail	 
		 If Len(Request.form("txt_email_vis")) > 0 and Len(Request.form("txt_email_vis")) < 5 Then
			OK = 0
		 Else
		   If InStr(1, Request.form("txt_email_vis"), "@", 1) < 2 Then
			   OK = 0
		   Else
			 If InStr(1,Request.form("txt_email_vis"), ".", 1) < 4 Then
			   OK = 0
			 End If
		   End If
		 End If
		'depois de validado o e-mail vamos validar o resto das entradas	
		if len(Request.form("txt_nome_vis")) < 1 then
		   OK = 0
		end if   
		if len(Request.form("txt_mensagem_vis"))<= 8 then
		   OK = 0
		end if
	   'se tudo estiver validado vamos então introduzir os dados na base dados
		if OK = 1 then
		  Set RS2 = Server.CreateObject("ADODB.Recordset")
		  ' esta é a maneira mais primária de introdução de dados na BD, mas é bom saber alternativas	
		  SQLStmt = "SELECT * FROM tbl_livro"
		  RS2.Open SQLstmt,Conn,1,2
		  RS2.AddNew
		  
			' vamos buscar a informação do nome do form
			nome_ = Request.form("txt_nome_vis")
			' vamos formatar as tags de HMTL
			'nome_ = Server.HTMLEncode(nome_)	
			' retiramos as replicas para não haverem problemas com a BD
			'nome_ = Replace(nome_, "'", "") 
			RS2("nome_vis") = nome_
		   
			email_ = Request.form("txt_email_vis")		
			'email_ = Server.HTMLEncode(email_)	
			'email_ = Replace(email_, "'", "") 
			RS2("email_vis") = email_
		   
			mensagem_ = Request.form("txt_mensagem_vis")
			'mensagem_ = Server.HTMLEncode(mensagem_)	
			'mensagem_ = Replace(mensagem_, "'", "") 		
			RS2("mensagem_vis") = mensagem_
		   
			RS2("data_livro") = day(now) & "/" & month(now) & "/" & year(now)
		  RS2.Update
		  RS2.Close   
		end if
	   
	   ' vamos então buscar as mensagens em Base de Dados ordenadas por data
		SQLStmt = "SELECT * FROM tbl_livro ORDER BY cod_livro DESC"
		RS.Open SQLstmt,Conn,1,2
%>

<html>

<head>
  <title> Livro de Visitas </title>
</head>

<body  BGCOLOR="#385FC6" TEXT="#000000" LINK="#0000FF" ALINK="#FF0000" VLINK="#C0C0C0">

<div align="center">
<table border="0" width="90%">
<tr>
  <td width="100%">
	<div align="center">
	<table border="0" width="90%">
	<% While Not RS.EOF %>
	<tr>		
	  <td width="100%" bgcolor="#000080">
		<font face="Arial" color="#E7F4D8"> <strong> Enviado em: </strong> </font>
		<font color="#00FF00"> <%= RS("data_livro")%> </font> <br>
		<font face="Arial" color="#E7F4D8"><strong>Por:  </strong> </font>
		<font color="#00FF00"> 
		  <a href="mailto:<%= RS("email_vis")%>">
		   <%=RS("nome_vis")%>
		  </a> <br>
		</font>
		<div align="left">
		<table border="0" width="70%">
		<tr>
		  <td width="100%"> <div align="left">
			<font face="Arial" color="#E7F4D8"><strong>Mensagem:  </strong> </font>
			<font color="#FFFF80" face="Arial">
			 <strong> 
			  <%=RS("mensagem_vis")%>
			 </strong>
			</font>
		  </td>
		</tr>
		</table>
		</div>
	  </td>
	</tr>
	<%
	  RS.MoveNext 
	  Wend
	  RS.close
	%>
	</table>
	</div>
  </td>
</tr>
</table>
</div>

<% ' Os valores das variáveis são zerados
   txt_nome_vis	 = ""
   txt_email_vis	= ""
   txt_mensagem_vis = ""
%>

<form name="form_livro" method="POST" action="guestbook.asp">
<font face="Arial">
 <strong>
  <font color="#E7F4D8">
	 Nome:
  </font> 
 </strong>
</font>
<input type="text" name="txt_nome_vis" value="<%=txt_nome_vis%>" size="20">

<br><br>

<font face="Arial" color="#E7F4D8">
 <strong>  
	E-Mail: 
 </strong>
</font>
<input type="text" name="txt_email_vis" value="<%=txt_email_vis%>" size="20">

<br><br>

<font face="Arial" color="#E7F4D8">
 <strong>  
  Mensagem: <br>
 </strong>
</font>
<textarea rows="3" name="txt_mensagem_vis" value="<%=txt_mensagem_vis%>" cols="38"> </textarea>

<br>								

<input type="submit" value="   Assinar   " name="B1">
<input type="reset" value=" Reset " name="B2">
</form>

</body>
</html>

está aparecendo esse erro quando eu assino

 

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

 

Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.

 

More information about this error may be available in the server error log.

 

O que está acontecendo?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.