Universal Form Validator ASP Support Product Page
Exists in database problem
Reported 15 May 2010 12:14:15
1
has this problem
15 May 2010 12:14:15 Paul Ogier 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 doesn't submit or pop up and error. 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 file="Connections/conn_admin1.asp" --> <!--#include file="ScriptLibrary/dmxValidator.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.4 dim dmxval1, DMX_validateAction set dmxval1 = new dmxValidator dmxval1.ScriptFolder = "ScriptLibrary" dmxval1.CSValidateOnChange = true dmxval1.CSValidateOnSubmit = true dmxval1.ReenableJavascript = true dmxval1.UseBotCheck = true dmxval1.ReportType = 4 dmxval1.ErrorFont = "Arial" dmxval1.ErrorFontSize = 12 dmxval1.ErrorColor = "#ffffff" dmxval1.ErrorBold = true dmxval1.ErrorItalic = false dmxval1.ErrorImage = "" dmxval1.ErrorFixed = "Custom" dmxval1.ErrorPadding = 4 dmxval1.BorderColor = "#FF0000" dmxval1.CssErrorFile = "validatorError5" 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", "user_name", "ajaxexistscond", "validatorAjax/dmxValidatorAjax16.asp,,", "true", "This username already exists", "", "", "" 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_conn_admin1_STRING MM_editCmd.CommandText = "INSERT INTO users (user_name) VALUES (?)" MM_editCmd.Prepared = true MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 255, Request.Form("user_name")) ' adVarWChar MM_editCmd.Execute MM_editCmd.ActiveConnection.Close End If End If %> <!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/validatorError5.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 %> </head> <body> <form action="<%=MM_editAction%>" method="post" name="form1" id="form1"> <table align="center"> <tr valign="baseline"> <td nowrap="nowrap" align="right">User_name:</td> <td><input type="text" name="user_name" value="<%= dmxSetValue("", FormRequest("user_name")) %>" size="32" /> <% dmxval1.GenerateError "form1","user_name","ajaxexistscond","validatorAjax/dmxValidatorAjax16.asp,," %> </td> </tr> <tr valign="baseline"> <td nowrap="nowrap" align="right"> </td> <td><input type="submit" value="Insert record" /> </td> </tr> </table> <input type="hidden" name="MM_insert" value="form1" /> <% dmxval1.ShowBotCheckError() %> </form> <p> </p> </body> </html>
Please help.
Replies
Replied 17 May 2010 10:15:57
17 May 2010 10:15:57 Miroslav Zografski replied:
Hello Paul,
I would like to see the code of the following file :
validatorAjax/dmxValidatorAjax16.asp
Regards,
I would like to see the code of the following file :
validatorAjax/dmxValidatorAjax16.asp
Regards,
Replied 17 May 2010 10:29:58
17 May 2010 10:29:58 Paul Ogier replied:
Here you go. I haven't touched this:
<!--#include file="../Connections/conn_admin2.asp" --> < %Response.CacheControl = "no-cache" Response.AddHeader "Pragma", "no-cache" Response.Expires = -1 On Error resume Next Dim sTable, sColumn, sValid, sInvalid, sField sTable = "users" sColumn = "user_name" sValid = "true" sInvalid = "false" sField = "user_name" Dim dmxValRs Dim dmxValRs_cmd Dim dmxValRs_numRows Set dmxValRs_cmd = Server.CreateObject ("ADODB.Command") dmxValRs_cmd.ActiveConnection = MM_conn_admin2_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 %>
Replied 17 May 2010 11:33:51
17 May 2010 11:33:51 Miroslav Zografski replied:
Hello Paul,
Seems fine to me. Check also if all necessary files are uploaded to your server as well.
if still the validation is not working, please, provide a link to the testing page.
Regards,
Seems fine to me. Check also if all necessary files are uploaded to your server as well.
if still the validation is not working, please, provide a link to the testing page.
Regards,
Replied 18 May 2010 10:21:07
18 May 2010 10:21:07 Paul Ogier replied:
Thanks for all your help. It was a problem with parent paths not being enabled. It works perfectly now.
Replied 18 May 2010 10:39:09
18 May 2010 10:39:09 Miroslav Zografski replied:
Hello Paul,
Thanks for your feed back,
Regards,
Thanks for your feed back,
Regards,