Improving my add.asp page (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


crosscreek -> Improving my add.asp page (3/11/2008 0:31:40)

I am trying to improve my asp page that will add dogs to my database.

If someone submits a blank form then they get a "must type something in"
If someone trys to add a duplicate, then gets "dog already in database"
If they type in a dog's name that neither choices above then the dogs added.

Now I am able to do the 1st two, but can't get the code to add the dog if the first two codes are false.

This is that I have so far...Now I will fix it for SQL injection, I just want to get it to work first.

Dim objrs, bolalreadyexists
If Request.form("doggy") = "" OR Request.form("doggy") = " " Then
Response.Write ("No Search Text Entered! YOu must type a name.")
Response.Write ("<a href='adddog.htm'> Click to go back to the Add dog Page page")
Else
bolalreadyexists = false
Set objrs = Server.CreateObject("ADODB.Recordset")
objRS.open "tbldog", myConn, , adlockoptimistic, adcmdtable
Do while not (objrs.eof OR bolalreadyexists)
If (strcomp(LCase(objrs("name")), request.form("doggy"), vbBinaryCompare) = 0) then
Response.write "This dog has already been entered. Please go back to enter a new dog in or click below to go to the pedigree page."
Response.Write "<a href=""pedigree.asp?id="&objRS("ID")&""">" & objRS("name") & "</a>"
bolalreadyexists = true
End if
objrs.movenext
Loop

If not bolalreadyexists then
objRS.AddNew
objRS("name") = Request.form("doggy")
objRS.Update
Response.write "you have added the dog"
End if

objrs.close
set objrs = nothing

End if

myConn.close
Set myConn = nothing


HELP!





crosscreek -> RE: Improving my add.asp page (3/11/2008 1:50:35)

quote:

Response.Write "<a href=""pedigree.asp?id="&objRS("ID")&""">" & objRS("name") & "</a>"


For some reason it didn't like this. It's a hyperlink to the duplicated dog in the database. Once I took that out...worked great.
Thanks
Helena




rdouglass -> RE: Improving my add.asp page (3/11/2008 14:31:00)

quote:

&""">


I think it's right in that mess. I hate using double double quotes in ASP - I always get lost.[:'(] [:D]

That's why I either use just apostrophes in links or if I need them as in a JavaScript, I'll use CHR(034) instead as in:

Response.Write "<a href="& CHR(034) & "pedigree.asp?id="&objRS("ID")& CHR(034) & ">" & objRS("name") & "</a>"

Once you get used to seeing it, it's a whole lot easier IMO.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.0625