close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

I have looked at this for 5 hours now... stuck

Thread began 3/26/2010 3:59 am by dinohorn397192 | Last modified 3/26/2010 2:21 pm by dinohorn397192 | 760 views | 2 replies |

dinohorn397192

I have looked at this for 5 hours now... stuck

I created a registration form, if the email exists, I display the error message. Sounds simple, but I can't get this to work. I'm at my wits end.

I created this simple example to show what I'm trying to get down. Right now, every submission shows the error message.

Thanks,


<?php require_once('Connections/pawtabs_db.php'); ?>
<?php require_once("WA_ValidationToolkit/WAVT_Scripts_PHP.php"); ?>
<?php require_once("WA_ValidationToolkit/WAVT_ValidatedForm_PHP.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;
}
}

$colname_checkRS = "-1";
if (isset($_POST['email'])) {
$colname_checkRS = (get_magic_quotes_gpc()) ? $_POST['email'] : addslashes($_POST['email']);
}
mysql_select_db($database_pawtabs_db, $pawtabs_db);
$query_checkRS = sprintf("SELECT UserID FROM users WHERE UserEmail = %s", GetSQLValueString($colname_checkRS, "text"));
$checkRS = mysql_query($query_checkRS, $pawtabs_db) or die(mysql_error());
$row_checkRS = mysql_fetch_assoc($checkRS);
$totalRows_checkRS = mysql_num_rows($checkRS);
?><?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$WAFV_Redirect = "";
$_SESSION['WAVT_signup_175_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM($row_checkRS['UserID'] . "",-1,0,"",",.",true,1);

if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"signup_175");
}
}
?>
<!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>
</head>

<body>


<form method="post" id="signup_form" name="signup_form" >

<input name="email" id="email" type="text" value="" /><br />
<?php
if (ValidatedField('signup_175','signup_175')) {
if ((strpos((",".ValidatedField("signup_175","signup_175").","), "," . "1" . ",") !== false || "1" == "")) {
if (!(false)) {
?>
email exists
<?php //WAFV_Conditional sign_up.php signup_175(1:)
}
}
}?>
<input name="sign_up_now" id="sign_up_now" type="submit" value="Join!" />

</form>
</body>
</html>
<?php
mysql_free_result($checkRS);
?>

Sign in to reply to this post

Ray BorduinWebAssist

Validate:

$totalRows_checkRS

not:

$row_checkRS['UserID']

your current validation would only pass if the UserID of the user was -1 or 0, which will never happen and it always says it isn't valid... like you mention.

If you validate the number of rows instead of the row result I think it will work:

$WAFV_Errors .= WAValidateNM($totalRows_checkRS . "",-1,0,"",",.",true,1);

Sign in to reply to this post

dinohorn397192

You are a savior!!!!! Thanks, what a relief.

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...