The Forum has been Updated
The code has been upgraded to the latest .NET core version. Please check instructions in the Community Announcements about migrating your account.
I would like to block out users with certain e-mail domains (i.e. gmail, hotmail) from submitting a form on my site. I would like to do that on the server side to prevent users from tampering with JavaScript. I do not want to use a database driven one and am thinking about using an array. If someone can point me to a sample code that would be great.
Regards,
Mo
Mo
نوشته شده در
I put this toghther. If it can be improved, please let me know.
Code:
<%
DIM EmailArray(4)
EmailArray(0) = "yahoo"
EmailArray(1) = "hotmail"
EmailArray(2) = "gmail"
EmailArray(3) = "netzero"
EmailArray(4) = "test"
strEmail = "MyEmail@MyCompany.com"
' strEmail = Request.Form("Email")
For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
End If
Next
If Flag = True Then
Response.Write "Bad E-mail"
ELSE
Response.Write "Good E-mail"
End If
%>
Regards,
Mo
Mo
نوشته شده در
If it were me, I'd reconsider using a db. One advantage to a database-driven list is you can use your db query tool to add or remove entries without having to edit and upload files, assuming you're not using Access, anyway. Although even with access you could use an app like table editor to make db changes.
======
Doug G
======
Computer history and help at www.dougscode.com
Doug G
======
Computer history and help at www.dougscode.com
نوشته شده در
Code:
For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
End If
Next
Code:
For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
exit for
End If
Next
_-/Cripto9t\-_
نوشته شده در
Originally posted by cripto9tCode:Just looking at it, I think you need to exit the loop once it's true. Because it will always come out false unless it's the last one in the list.For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
End If
NextCode:For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
exit for End If
Next
I think the following will improve it a little.
Code:
<%
DIM EmailArray(4)
EmailArray(0) = "@yahoo.com"
EmailArray(1) = "@hotmail.com"
EmailArray(2) = "@gmail.com"
EmailArray(3) = "@netzero.com"
EmailArray(4) = "@test.com"
strEmail = "MyEmail@MyCompany.com"
' strEmail = Request.Form("Email")
For i = 0 to UBound(EmailArray)
If InStr(1,strEmail,EmailArray(i),1) Then
Flag = True
Exit For
End If
Next
If Flag = True Then
Response.Write "Bad E-mail"
ELSE
Response.Write "Good E-mail"
End If
%>
This way you eleminate a domain as "MyTest" from being flagged as a bad domain.
Regards,
Mo
Mo
Email Member
Message Member
Post Moderation
بارگزاری فایل
If you're having problems uploading, try choosing a smaller image.
پیشنمایش مطلب
Send Topic
Loading...