close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Checking to see if email already exists in Database

Thread began 4/13/2010 6:45 am by John Langer | Last modified 7/01/2010 6:55 am by Jason Byrnes | 5153 views | 8 replies |

John LangerBeta Tester

Checking to see if email already exists in Database

I'm posting this here as it's VTK specific although I'm working from a CSS Forn Builder Form.

So I adapted the registration form a bit (just deleted a few fields). Then added an Insert Record behaviour.

Then tested and it all works great.

I then decided to add one more validation to the email field. The idea is to compare the email submitted with emails already stored in the Users database and say "That Email already exists" if there is a match.

Firstly the form shows that error ALL the time regardless of anything.

Secondly the form does not submit even if the emails do NOT match. (It doesn't submit if they do match but that's the expected behaviour). If I delete the validation (Like Entry) then it goes back to working properly.

I have temporarily bound the recordset email address to the page and they are displaying correctly.

I've attached my page if anyone could have a look. It must be something I'm doing wrong but I can't spot it.

Many thanks.

Sign in to reply to this post

John LangerBeta Tester

Mmm the attachment didn't attach. Here it is again.

Sign in to reply to this post

Jason ByrnesWebAssist

the problem is that the recordset code is after the server validation code, the recordset code needs to be moved so it is before the server validation code.


also, the recordset is not being filtered, you should filter the email columnb on the email form element.

Instead of using like entry validation, use number validation. the idea is to check that the rcordset is empty.

for the server variable, use $totalRows_rsEmailMatch. In the number validation settings, set the minimum number to -1 and the max to 0

Sign in to reply to this post

John LangerBeta Tester

Hi Jason, many thanks for your help once again.

I think I've corrected it as you said although I wasn't too sure of what you meant by filtering the recordset email column on the email form element. However I had an educated guess. I'm now getting this error show up in the browser:
Fatal error: Call to undefined function getsqlvaluestring() in C:\wamp\www\CardiffMensConferences\my_area\users_Registration.php on line 12

Line 12 is: $query_rsEmailMatch = sprintf("SELECT * FROM users WHERE UserEmail = %s", GetSQLValueString($colname_rsEmailMatch, "text"));

But I once again attach the whole page with the revised code if you wouldn't mind having another look.

Sign in to reply to this post

Jason ByrnesWebAssist

1) The filter is set to use the server collection:
$_SERVER['Registration_group_Email_address']

It should be set to use the POST collection:
$_POST['Registration_group_Email_address']


2) The error is caused by code order still.

Move the following code:

php:
<?php

if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  if (
PHP_VERSION 6) {
    
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
?>



to line 6 so it is before the recordset.

Sign in to reply to this post

John LangerBeta Tester

Many thanks Jason. That did the trick.

So much to learn...

Sign in to reply to this post

Jason ByrnesWebAssist

no worries, glad to hear it's working.

Sign in to reply to this post

info368164

Hallo
ASP Server validation:

many times I have the necessity to compare two value, one in the textbox and another one in the db; if the values are the same the answer must be a error...
I haven't find of better who...
1) apply the command "Like Entry" whit a little modify:

if not recordset1.EOF or Not recordset1.BOF then
mailx=(recordset1.Fields.Item("mail").Value)
else
mailx="xyz@xyz.com" ' to bypass empty value
end if

WAFV_Errors = WAFV_Errors & WAValidateNOLE(cStr(Request.Form("email")) & "", mailx & "",true,2)



2) modify the code in WAVT_Scripts_VB.asp and add this function:

function WAValidateNOLE(value1,value2,required,number)
dim WAFV_ErrorMessage, isValid
WAFV_ErrorMessage = ""
isValid = true
if (value1 = value2 OR (required AND value1 = "")) then
isValid = false
end if
if (NOT isValid) then
WAFV_ErrorMessage = WAFV_ErrorMessage & "," & number
end if
WAValidateNOLE = WAFV_ErrorMessage
end function



Exist another method? If no, is possible to add this function (unLike Entry) at the next update?

Thank you
Regards
Luca

Sign in to reply to this post

Jason ByrnesWebAssist

The two solutions you have proposed are the best way to handle this in ASP.

This will not be added to a future update however since we are no longer developing for ASP. We are focusing our developing efforts on PHP.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...