Forums
This topic is locked
Check if two field entries in one record exists
19 May 2005 02:29:49 Dom Fee posted:
Hi there i'm looking for an extension or a solution to the following topic that has allready been covered:<b>Check if two field entries in one record exists</b>
What I am looking for is very simple - a server behaviour similar to the "Check if username exists" server behaviour. However, I would like to check for the existance of two field entries in a particular record and not only one - for example I would like to check for the existance of the person's username as well as the title of a particular article he would like to save to his list of favourites. Should this particular article allready have been saved to his list of favourites, I would like to redirect him to a page that will inform him that the article allready exists in his list of saved articles.
Any help would be brilliant, as its a bit over my head this one
Kindest Regards
Dom
Replies
Replied 27 May 2005 18:32:38
27 May 2005 18:32:38 John Lee replied:
I think you can create a validation page lets call it val_favarite.asp
post your form to val_favarite.asp
in val_favarite.asp, create an query to see it has records (query should be like this: select * from your_table where your_condition)
then if there is record, then redirect to the page, if not redirect to other page.
by the way, you need to let us know more detial to help you such as table names will be helpful.
John Lee
post your form to val_favarite.asp
in val_favarite.asp, create an query to see it has records (query should be like this: select * from your_table where your_condition)
then if there is record, then redirect to the page, if not redirect to other page.
by the way, you need to let us know more detial to help you such as table names will be helpful.
John Lee
Replied 27 May 2005 18:54:31
27 May 2005 18:54:31 adam partridge replied:
i think this is what u want :
<pre id=code><font face=courier size=2 id=code> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="file:mycheekylittlewebsite.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("MM_username" <> "" Then
Recordset1__MMColParam = Session("MM_username"
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_encams_STRING
Recordset1.Source = "SELECT * FROM dbo.tblusers WHERE strusername = '" + Replace(Recordset1__MMColParam, "'", "''" + " AND strfavourite <> '''"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<p>they have a favourite</p>
<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
<% If Recordset1.EOF And Recordset1.BOF Then %>
<p>they dont </p>
<% End If ' end Recordset1.EOF And Recordset1.BOF %>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
</font id=code></pre id=code>
<pre id=code><font face=courier size=2 id=code> <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="file:mycheekylittlewebsite.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Session("MM_username" <> "" Then
Recordset1__MMColParam = Session("MM_username"
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_encams_STRING
Recordset1.Source = "SELECT * FROM dbo.tblusers WHERE strusername = '" + Replace(Recordset1__MMColParam, "'", "''" + " AND strfavourite <> '''"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<p>they have a favourite</p>
<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
<% If Recordset1.EOF And Recordset1.BOF Then %>
<p>they dont </p>
<% End If ' end Recordset1.EOF And Recordset1.BOF %>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
</font id=code></pre id=code>