Forums

This topic is locked

check form field against database field

Posted 01 Jan 2003 19:29:32
1
has voted
01 Jan 2003 19:29:32 Dave Clarke posted:
Hi
I need to check a users form input against a database field and if the value from the form already exists in the database then redirect (similar sort of thing to the UD4 'check new user' behaviour)
was thinking along the lines of

If Request.Form("formfield" = (rset.Fields.Item("fld".Value) THEN Response.Redirect("alreadyexists.asp"

whereabouts would this code, if its suitable, go in the page?

thanks in advance

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Replies

Replied 02 Jan 2003 02:01:10
02 Jan 2003 02:01:10 Owen Eastwick replied:
Needs to go somewhere after "rset" recordset code on the page to which the form is being submitted.

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 02 Jan 2003 17:19:45
02 Jan 2003 17:19:45 Dave Clarke replied:
thanks owen

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 02 Jan 2003 18:28:52
02 Jan 2003 18:28:52 Dave Clarke replied:
I have put this code directly below the recordset code on the page that receives the form but it is still inserting the field into the database rather than redirecting.
I've tested it by copy & paste so that I know the new value is exactly the same as the one already in the database.

<b>&lt;%
If Request.Form("addmessage" = rsetAllmessages.Fields.Item("Message".Value Then response.redirect ("addmess.asp"
%&gt;</b>


Any more help please??

thanks

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Edited by - Davecl on 02 Jan 2003 18:29:33
Replied 02 Jan 2003 19:34:00
02 Jan 2003 19:34:00 Owen Eastwick replied:
Are you using DW's insert record behavior?

If so, don't, use Command (Stored Procedure), then set up the INSERT command as follows:

INSERT INTO TableName(Field1Name, Field2Name) VALUES ('var1', var2)

Then set up the page something like:

&lt;%
RECORDSET CODE
%&gt;
&lt;%
If Request.Form("addmessage" = rsetAllmessages.Fields.Item("Message".Value Then response.redirect ("addmess.asp"
%&gt;
&lt;%
INSERT RECORD CODE
%&gt;

You might find that easier than trying to fathom the messy code that DW's INSERT record behavior generates.

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo
Replied 02 Jan 2003 19:57:59
02 Jan 2003 19:57:59 Dave Clarke replied:
Thanks Owen

Yes I am using the DW insert behaviour, I will try the COMMAND instead.

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Reply to this topic