Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/07/2004, 08:35
marco7661
 
Fecha de Ingreso: febrero-2004
Mensajes: 14
Antigüedad: 20 años, 2 meses
Puntos: 0
Validar campo e insertar url de la visita en Access

Hola, tengo el siguiente formulario para el boletín de noticias de mi web. La duda que tengo es como puedo validar el campo "Nombre" para que lo envien vacio y como puedo insertar en la base de datos access la dirección ip del visitante, además de la información que ya envia?

Saludos y gracias



<%@ Language=VBScript%>
<%

Comentario2 = Request.Form("comentario")
nombre= Request.Form("nombre")

if Comentario2 <> "" then

Set conn=Server.CreateObject("ADODB.CONNECTION")
Set RS=Server.CreateObject("ADODB.RECORDSET")


Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&Server.MapPath("..\data/boletin.mdb")




SQL="INSERT INTO email (email,nombre) VALUES ('"&Comentario2&"','"&nombre&"');"



Conn.Execute(SQL)
Conn.Close


end if

%>


<!-- Botón derecho del mouse -->

<script LANGUAGE="JavaScript1.1">

function derecha(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
alert('')
return false;
}

else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)){
alert('')
}
}
document.onmousedown=derecha
</script>
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Pagina nueva 2</title>
</head>

<body bgcolor="#FFFEEA">



<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="462" id="AutoNumber1" height="16">
<tr>
<td width="100%" height="315" valign="top">
<p align="center"><font face="Verdana" style="font-size: 10pt"><br>
Si desea que le tengamos, puntualmente, informado y recibir nuestros boletines de
<u><b>Ofertas y Novedades</b></u>, no tiene m&aacute;s que indicarnos su e-mail y recibir&aacute; dicha informaci&oacute;n en su correo electr&oacute;nico. </font><br>
&nbsp; </p>

<FORM ACTION="boletin.asp?dado=1" METHOD="POST" name="myform">
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-top-width:0; border-bottom-width:0" bordercolor="#111111" width="96%" id="AutoNumber2" height="148">
<tr>
<td width="100%" align="center" bgcolor="#0066CC" height="13" colspan="2" style="border-left-color: #111111; border-left-width: 1; border-right-color: #111111; border-right-width: 1; border-top-color: #111111; border-top-width: 1">
<font face="Verdana" style="font-size: 8pt" color="#FFFFFF">BOLETÍN DE OFERTAS Y NOVEDADES </font></td>
</tr>
<tr>
<td width="100%" align="center" bgcolor="#E7F5FE" height="13" colspan="2" style="border-left-color: #111111; border-left-width: 1; border-right-color: #111111; border-right-width: 1">
<font face="Verdana" style="font-size: 8pt">Introduzca su E-mail </font></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#B0E8FD" height="38" style="border-left-style: solid; border-left-width: 1; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium">
Nombre:</td>
<td width="85%" align="center" bgcolor="#B0E8FD" height="38" style="border-left-style: none; border-left-width: medium; border-right-style: solid; border-right-width: 1; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium">
<INPUT TYPE="text" NAME="nombre" size="58" maxlength=255 style="font-size: 8pt; font-family: Verdana"></td>
</tr>
<tr>
<td width="15%" align="center" bgcolor="#B0E8FD" height="48" style="border-left-style: solid; border-left-width: 1; border-right-style: none; border-right-width: medium; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium">
Email:</td>
<td width="85%" align="center" bgcolor="#B0E8FD" height="48" style="border-left-style: none; border-left-width: medium; border-right-style: solid; border-right-width: 1; border-top-style: none; border-top-width: medium; border-bottom-style: none; border-bottom-width: medium">
<INPUT TYPE="text" NAME="comentario" size="58" maxlength=255 style="font-size: 8pt; font-family: Verdana"></td>
</tr>
<tr>
<td width="100%" align="center" bgcolor="#E7F5FE" height="31" colspan="2" style="border-left-color: #111111; border-left-width: 1; border-right-color: #111111; border-right-width: 1; border-bottom-color: #111111; border-bottom-width: 1">
<font face="Verdana" size="1">
<INPUT TYPE="submit" VALUE="Enviar" style="font-family: Verdana; font-size: 10px"></font></td>




</tr>
</table>
</center>
</div>
</form>

<% if comentario2 <> "" then %>
<font face="Verdana" style="font-size:10pt">
<b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp<%= "Su email ha sido procesado satisfactoriamente" %></b>
</font></td>
<%end if%>

</td>
</tr>
<tr>
<td width="100%" height="71" valign="top">


</font></td>
</tr>
</table>



<script language="vbs">

function myform_onsubmit()


if(myform.comentario.value<>"")then

if(instr(1,myform.comentario.value,"@")=0)then
msgbox "Error : Dirección e-mail no válida." & chr(32)&chr(10) & "Ejemplo : [email protected]try "& chr(32)&chr(10) &" "& chr(32)&chr(10) & " INTRODUZCA DE NUEVO SU EMAIL ",vbexclamation,"Error de sintaxis"
myform.comentario.select()
myform_onsubmit=false
else



if(instr(1,myform.comentario.value,".")<>0)then


if(instr(1,myform.comentario.value,".")=len(myform .comentario.value))then



alert "La dirección no tiene un dominio"
myform.comentario.select
myform_onsubmit=false



end if

else
alert "La dirección de correo no es válida"
myform.comentario.select
myform_onsubmit=false
end if


if(instr(1,myform.comentario.value,chr(32))<>0)the n
alert "Un correo electrónico no puede usar espacios en blanco"&chr(32)&chr(10)&"El programa suprimirá los espacios en blanco."
myform.comentario.value=replace(myform.comentario. value,chr(32),"",1,1000)

end if

end if
elseif(myform.comentario.value="")then
alert "Por favor escriba una dirección e-mail"
myform_onsubmit=false
end if



end function

</script>