473,800 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Advanced server-side form validation

Can anybody point me to a good tutorial/manual on advanced server-side
form validation including validation of fields against unwanted
strings such as the use of "http://".

Thank you in advance,

FayeC
Jul 15 '06 #1
2 2379

FayeC wrote:
Can anybody point me to a good tutorial/manual on advanced server-side
form validation including validation of fields against unwanted
strings such as the use of "http://".

Thank you in advance,
You can go two ways with this kind of thing, depending on how complex
your validation is and what action you want to take as a result of
invalid data. Your example is straightfoward. Use of instr against
the string will find whether something like "http://" is in there.
Most of these tasks can be accomplished using the built-in functions.
More complex tasks might benefit from the use of Regular Expressions.

http://msdn.microsoft.com/library/de...ting051099.asp

--
Mike Brind

Jul 15 '06 #2
On Sat, 15 Jul 2006 16:49:30 -0500, FayeC <fa*******@hotm ail.comwrote:
Can anybody point me to a good tutorial/manual on advanced server-side
form validation including validation of fields against unwanted
strings such as the use of "http://".
I have no specific references to direct you to, but I tend to create a
class for each form that has one method which reads the form data from a
collection (usually one of either the QueryString or Form properties of
the Request object), and a second that returns True if the data is
valid. The form data itself is exposed as properties, and there is
usually a collection of error messages that is populated by the
validation method. Even if you never use the form in more than one
place, it's nice to get all the form processing code out of the main
flow of the page.

A quick 'n dirty (and rather obnoxious) new account form using this
style follows.

Class NewAccountForm
Public UserName
Public Password1
Public Password2
Public Email
Public WhatNumberAmITh inkingOf

Public Messages

Function Init(form)
UserName = Trim(form("user name"))
Password1 = Trim(form("pass word1"))
Password2 = Trim(form("pass word2"))
Email = Trim(form("emai l"))

WhatNumberAmITh inkingOf = form("whatnumbe ramithinkingof" )
If IsNumeric(WhatN umberAmIThinkin gOf) Then
WhatNumberAmITh inkingOf = CLng(WhatNumber AmIThinkingOf)
Else
WhatNumberAmITh inkingOf = 0
End If

Set Init = Me
End Function

Function DataValid()
DataValid = True

If Len(UserName) = 0 Then
Messages("usern ame") = "Please enter a username."
DataValid = False
End If

If Len(Password1) = 0 Then
Messages("passw ord1") = "Please enter password."
DataValid = False
ElseIf Password1 <Password2
Messages("passw ord1") = "Passwords do not match."
DataValid = False
End If

If Len(Email) = 0 Then
Messages("email ") = "Please enter an email address."
DataValid = False
ElseIf InStr(Email, "@") = 0 Or InStr(Email, ".") = 0 Then
Messages("email ") = "Please enter a valid email address"
DataValid = False
End If

If WhatNumberAmITh inkingOf <5 Then
Messages("whatn umberamithinkin gof") = "Ha! Nice try, buddy!"
DataValid = False
End If
End Function

Private Sub Class_Initializ e
Set Messages = CreateObject("S cripting.Dictio nary")
End Sub
End Class

--
Justin Piper
Bizco Technologies
http://www.bizco.com/
Jul 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1302
by: Michael J. Wendell | last post by:
Hello, I am trying to debug an issue with sessions in my ASP 3.0 web application, which runs fine on WIN2K Pro and WINXP Pro, yet fails to function correctly on WIN2K Advanced Server. My actual application is using sessions to store username, and security level (permissions) for my application. The default.asp page is the login, where these values are set. I have triple and quadruple checked my IIS Settings to make sure "Enable...
1
1568
by: Barb | last post by:
What is the limitation of memory that SQL Server 2000 Standard can use when running on a Windows 2000 Advanced Server platform?
3
2217
by: ChrisL | last post by:
I currently have two SQL server books for MS SQL Server 2000. One is a prep book for the 70-229 exam, the other is a Wrox book: "professional SQL Server 2000 Programming." I'm looking for more T-SQL books that give me PRACTICAL tips on writing advanced queries. What book do you refer to? Please post them.
6
1329
by: abhishekjha10 | last post by:
i was asked this question in an interview. the question is that " what do u mean by advanced architecture of c++" i was unable to answer. what can be the answer ?
0
987
by: Just D. | last post by:
All, What's the easiest way to create a Virtual Directory with required properties like: 1) delete all Start File names but insert only one required 2) one of the sub Directories should be Writable for this app 3) the VD should be created on a required Web Server? The complication is that our Windows Advanced Server 2000 has 3 Web Servers
1
2092
by: mosscliffe | last post by:
I wanted to install the SQL SERVER 2005 Express Advanced Services, because I wanted the import / export features of the data manager. I chose the route of deleting the template files and then installing, as my version of SQL Server express was part of the install, with Visual Web Developer 2005 Express Edition and I was not confident of re-installing just SQL Server Express. The install progressed quite nicely until I got the following...
1
2464
by: Parv | last post by:
I am trying to impersonate user to some other system using userName,domainName,password in C#. My Code is working fine if i am working on Windows 2000 professional after assigning current user "Act as part of Operating system" permission. But when i tried to do the same on Windows 2000 advanced server after assigning current user i.e. administrator or anyone else "Act as part of Operating system" permission it gives me error "A required...
3
7726
by: | last post by:
I'm planning to transport a desktop application to the web. A spin-off of this application has already been put on the web by another programmer. He used ColdFusion with MS SQL, Access, VC, and Java. It is faster than the desktop application (written in VFP). 1. Can I get the same results using MS SQL Express Advanced and Access for the internet version if used with .net? 2. Are the select statements limited in power, accuracy, size, etc....
2
1632
by: rajendrsedhain | last post by:
Hi, I have 1 checkboxlist, 5 dropdownlits and three textboxes.I have to write the SQL query and c# code for that advanced search. <asp:CheckBoxList ID="reposotoryCheckBoxList" runat="server" Style="z-index: 106; left: 226px;position: absolute; top: 18px"> asp:ListItem Text="computer" Value="2"></asp:ListItem> <asp:ListItem Text="math" Value="3"></asp:ListItem> <asp:ListItem Text="science" Value="1"></asp:ListItem>--%>
1
3664
by: BobLewiston | last post by:
I installed SQL Server 2008 Express, basic edition (SQLEXPR32_x86_ENU_Bootstrapper.exe, version 9.0.30729.1) without any problem. Then I attempted to install AdventureWorks Sample Databases for SQL Server 2008 (SQL2008.AdventureWorks_All_Databases.x86.msi). This attempt failed because SQL Server 2008 Express, basic edition doesn’t support Full-text Search, which AdventureWorks requires. So I uninstalled SQL Server 2008 Express, basic...
0
9694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10509
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10281
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10039
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7584
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5477
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4152
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2953
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.