Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2002, 05:58
luisgls
 
Fecha de Ingreso: noviembre-2002
Mensajes: 133
Antigüedad: 22 años, 6 meses
Puntos: 0
AYUDITA, QUE NO ES TAN FIERO EL LEON .....

Tengo el codigo del archivo profile_update.asp, que permite modificar el archivo personal de cada
usuario, sin embargo, en el campo de la contraseña solo se comprueba que no es un campo vacio y
necesito comprobar que es un correo correcto, tengo una funcion hecha. Y los 2 archivos funcionan
perfectamente por separado, sin embargo, no se cómo integrarlos. Gracias

Archivo profile_update.asp
<%
Option Explicit
Dim sql, rsUser, username, firstname, email, notfilled(2), badflag, count, calltype, password

username = Request.Cookies("username")

'Assign form values to variables

firstname = Request.Form("firstname")
email = Request.Form("email")
password = Request.Form("password")


'Check everything's been filled in, badflag determines whether error function is called
badflag = 0

if firstname = "" then
notfilled(0) = "First Name"
badflag = 1
end if
if email = "" then
notfilled(1) = "Email"
badflag = 1
end if
if password = "" then
notfilled(2) = "Password"
badflag = 1
end if

if badflag = 1 then
signuperror("nofield")
end if

'Open connection and insert user details into the database
%>
<%
Dim ConnectString, conn

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("siteusers.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString
%>
<%

Set rsUser = Server.CreateObject("ADODB.Recordset")
rsUser.open "users WHERE username = '" & username & "'", conn, 3, 3

if rsUser("password") = password then
rsUser("firstname") = firstname
rsUser("email") = email
rsUser.Update
else
signuperror("badpwd")
end if
rsUser.close
set rsUser = nothing
conn.close
set conn = nothing

Response.Redirect("profile.asp?updated=true")
%>


<%Function signuperror(errortype)%>
<html>
<head>
<title>Your Profile</title>
</head>
<body bgcolor="#FFFFFF" link="#DD0000" vlink="#DD0000" alink="#000000">
<font face="arial,helvetica" size=2>

<%if errortype = "nofield" then%>
<p><b>You have not filled in the following fields correctly:</b></p>

<p>
<%for count = 0 to 2%>
<%if notfilled(count) <> "" then%>
<b><%=notfilled(count)%></b><br>
<%end if%>
<%next%>
</p>

<%else%>

<p>Your password is incorrect</p>

<%end if%>

<p><a href="javascript:self.history.go(-1)">Please try again</a></p>

</font>
</body>
</html>
<%Response.end
End Function%>




Archivo IsEmailValid.asp

<%
Function IsEmailValid(strEmail)

Dim strArray, strItem, i, c

IsEmailValid = True

strArray = Split(strEmail, "@")

If UBound(strArray) <> 1 Then
IsEmailValid = False
Exit Function
End If

For Each strItem In strArray
' no part can be void
If Len(strItem) <= 0 Then
IsEmailValid = False
Exit Function
End If

For i = 1 To Len(strItem)
c = LCase(Mid(strItem, i, 1))
' if there is an illegal character in the part
If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
IsEmailValid = False
Exit Function
End If
Next

If Left(strItem, 1) = "." Or Right(strItem, 1) = "." Then
IsEmailValid = False
Exit Function
End If
Next

If InStr(strArray(1), ".") <= 0 Then
IsEmailValid = False
Exit Function
End If

i = Len(strArray(1)) - InStrRev(strArray(1), ".")
If i <> 2 And i <> 3 And i <> 4 Then
IsEmailValid = False
Exit Function
End If
If InStr(strEmail, "..") > 0 Then
IsEmailValid = False
Exit Function
End If

IsEmailValid = True

End Function
%>

Última edición por luisgls; 14/11/2002 a las 18:44