Simple ASP error...

Soldato
Joined
13 Feb 2004
Posts
2,656
Location
South Shields
Alreeet.

For some reason is always the simple things that I get errors on.. but I can plough through some of the more complex stuff..

So.. I'm having problems with an If, Then, Else statement :o

When the user inputs their forename I want the asp page to check the forename and make sure that it is only constructed with letters.. and no numbers or symbols.

Therefore I have created this code..

<%
'Open the database connection
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("Members.mdb")
%>

<%
'Add new member
sqlAddMember ="INSERT INTO Members ( `Member Salutation`, `Member Forename`, `Member Surname`, `Member Email Address`) VALUES ('" & Salutation & "', '" & Forename & "', '" & Surname & "', '" & Email & "')"

If Forename.contenttype="text" Then con.execute sqlAddMember
'Display confirmation message to the user.
Response.Write( Salutation & "&nbsp;" & Surname & " you have been successfully added to our email list")

Else Response.Write("There has been an error with your submission")

End If
%>

However it constantly shows the Salutation & "&nbsp;" & Surname & " you have been successfully added to our email list line but never actually adds the information to the database.

Any ideas.. have I missed anything obvious.

Also.. this input page works on IIS (if I comment out the If, Then, Else) and adds a user to the database. However it does not work on my ASP enabled host. Could this be a directory issue?

Thanks for looking :)
 
Thanks guys.. gonna try changing the code in a few mins..

@ PsychoDuck - The code works fine.. It was quite fiddly to code though..
However.. it might explain why it won't work on my web server.. so I'll give that a go too :)

Thanks again guys.. much appriciated :cool:
 
The new code that you guys helped me with works fine.. kinda lol.

What I'm trying to achieve is a form of validation.. that brings up an error if say a numerical character is entered instead of text.
I presumed that this would be contenttype but it appears not.. as if I inputted the forename Ian then it would process the page and search for an object known as Ian.
Any help is appreciated.. I'm going to throw my head in a few boks now to try and find the answer.. :)
 
Back
Top Bottom