Universal Form Validator ASP Support Product Page

In progress

Exists in Database problem

Reported 05 Oct 2011 05:21:11
1
has this problem
05 Oct 2011 05:21:11 Joseph Webb posted:
Hi there,

I am having major troubles trying to add the condition that says if the username exists, show error.

I have made a new page to try and see if there was something I was doing. It keeps showing an error "Invalid value...". I added a Dreamweaver insert form first then all i did was add the validate that says if it doesn't exist then valid.

Here is the code from a test page:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include virtual="/ScriptLibrary/dmxValidator.asp" -->
<!--#include file="Connections/frl_database_20688.asp" -->


<
%Dim MM_editAction
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
If (Request.QueryString <> "") Then
  MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
End If

' boolean to abort record edit
Dim MM_abortEdit
MM_abortEdit = false
%>
<
%' Universal Form Validator ASP 1.5.6
dim dmxval1, DMX_validateAction
set dmxval1 = new dmxValidator
dmxval1.ScriptFolder = "ScriptLibrary"
dmxval1.CSValidateOnChange = true
dmxval1.CSValidateOnSubmit = true
dmxval1.ReenableJavascript = true
dmxval1.UseBotCheck = false
dmxval1.ReportType = 4
dmxval1.ErrorFont =  "Arial"
dmxval1.ErrorFontSize = 12
dmxval1.ErrorColor = "#ffffff"
dmxval1.ErrorBgColor = "#ff0000"
dmxval1.ErrorBold = true
dmxval1.ErrorItalic = false
dmxval1.ErrorImage = ""
dmxval1.ErrorFixed = "Custom"
dmxval1.ErrorPadding = 4
dmxval1.BorderColor = "#FF0000"
dmxval1.CssErrorFile = "validatorError4"
dmxval1.ErrorPreset = "error_five.txt"
dmxval1.TooltipPosition = "top"
dmxval1.CssHintFile = "validatorHint5"
dmxval1.HintPreset = "blue.txt"
dmxval1.HintTooltipPosition = "top"
dmxval1.HintBorderColor = "#0099ff"
dmxval1.HintBorderStyle = "solid"
dmxval1.HintBgColor = "#003399"
dmxval1.HintTextColor = "#ffffff"
dmxval1.HintTextFont = "Arial"
dmxval1.HintTextSize = 12
dmxval1.HintTextBold = false
dmxval1.HintTextItalic = false
dmxval1.HintBoxWidth = 200
dmxval1.HintImage = ""
dmxval1.HintFixed = "Custom"
dmxval1.HintPadding = 4
dmxval1.UseCustomFocusClass = "fixed"
dmxval1.FocusBorderStyle = "groove"
dmxval1.FocusBorderSize = 2
dmxval1.FocusBorderColor = "#C3D9FF"
dmxval1.FocusBgColor = "#FFFFFF"
dmxval1.FocusTextColor = "#000000"
dmxval1.UseCustomValidClass = "fixed"
dmxval1.ValidBorderStyle = "groove"
dmxval1.ValidBorderSize = 2
dmxval1.ValidBorderColor = "#00FF00"
dmxval1.ValidBgColor = "#FFFFFF"
dmxval1.ValidTextColor = "#000000"
dmxval1.UseCustomInvalidClass = "fixed"
dmxval1.InvalidBorderStyle = "groove"
dmxval1.InvalidBorderSize = 2
dmxval1.InvalidBorderColor = "#FF0000"
dmxval1.InvalidBgColor = "#FFFFFF"
dmxval1.InvalidTextColor = "#000000"
dmxval1.AddRule "form1", "username", "ajaxexistscond", "validatorAjax/dmxValidatorAjax21.asp,,", "true", "", "username", "", ""
dmxval1.Validate
%>
<
%If (CStr(Request("MM_insert")) = "form1") Then
  If (Not MM_abortEdit) Then
    ' execute the insert
    Dim MM_editCmd

    Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    MM_editCmd.ActiveConnection = MM_frl_database_20688_STRING
    MM_editCmd.CommandText = "INSERT INTO regphotogallery (username) VALUES (?)" 
    MM_editCmd.Prepared = true
    MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203, 1, 1073741823, Request.Form("username")) ' adLongVarWChar
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close
  End If
End If
%>

<
%Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_frl_database_20688_STRING
Recordset1_cmd.CommandText = "SELECT * FROM regphotogallery" 
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<
%Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="Styles/dmxValidator/validatorHint5.css" type="text/css" />
<link rel="stylesheet" href="Styles/dmxValidator/validatorError4.css" type="text/css" />
<script type="text/javascript" src="ScriptLibrary/jsvat.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery-latest.pack.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery.inputHintBox.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery.maskedinput-1.2.2.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery.validate.min.js"></script>
<script type="text/javascript" src="ScriptLibrary/dmx.jquery.validate.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery.tooltip.min.js"></script>
<script type="text/javascript" src="ScriptLibrary/jquery.hoverIntent.min.js"></script>
<% 
' dmxValidatorJSStart
dmxval1.GenerateJavascriptAndCss
' dmxValidatorJSEnd
%>
<% 
' dmxValidatorJSStart
dmxval1.GenerateJavascriptAndCss
' dmxValidatorJSEnd
%>
</head>

<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
  <p>
    <label for="username">username</label>
    <input name="username" type="text" id="username" value="<%= dmxSetValue("", FormRequest("username")) %>" />
  <%= dmxval1.GenerateError("form1","username","ajaxexistscond","validatorAjax/dmxValidatorAjax21.asp,,") %></p>
  <p>
    <input type="submit" name="button" id="button" value="Submit" />
  </p>
  <input type="hidden" name="MM_insert" value="form1" />
</form>
<% 
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF)) 
%>
  <p><%=(Recordset1.Fields.Item("username").Value)%></p>
  <% 
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  Recordset1.MoveNext()
Wend
%>
</body>
</html>
<
%Recordset1.Close()
Set Recordset1 = Nothing
%>

And here is the dmxValidatorAjax21.asp page

<!--#include file="../Connections/frl_database_20688.asp" -->
<
%Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
On Error resume Next
Dim sTable, sColumn, sValid, sInvalid, sField
sTable = "regphotogallery"
sColumn = "username"
sValid = "false"
sInvalid = "true"
sField = "username"

Dim dmxValRs
Dim dmxValRs_cmd
Dim dmxValRs_numRows
	
Set dmxValRs_cmd = Server.CreateObject ("ADODB.Command")
dmxValRs_cmd.ActiveConnection = MM_frl_database_20688_STRING
dmxValRs_cmd.CommandText = "SELECT * FROM " & sTable & "  WHERE " & sColumn & "='" & Replace(Request.QueryString(sField), "'", "''") &"'"
dmxValRs_cmd.Prepared = true
Set dmxValRs = dmxValRs_cmd.Execute
dmxValRs_numRows = 0
If Err.Number <> 0 then
	Response.Write "false"
	Response.End
end if

If dmxValRs.EOF Then
	Response.Write sValid
Else
	Response.Write sInvalid
End If

dmxValRs.Close()
Set dmxValRs = Nothing
%>

Promoted Solutions

Replied 06 Oct 2011 09:46:47
Hello Joseph,

Issue is under investigation. Will notify you here on any progress.

Replies

Replied 06 Oct 2011 09:46:47
06 Oct 2011 09:46:47 Miroslav Zografski replied:
Hello Joseph,

Issue is under investigation. Will notify you here on any progress.

Replied 07 Oct 2011 00:35:39
07 Oct 2011 00:35:39 Joseph Webb replied:
Thanks

Reply to this topic