kvarnerexpress 0 Report post Posted September 11, 2005 im having some trouble with thisPHP Code: while ($checking = mysql_fetch_array($check)){ $usr = $checking['loguser']; $mail = $checking['logemail']; $error = ""; if ($mail == $email){ $erroremail = "the email address you have chose is already taken"; $error = 1; } if ($usr == $user) { $errorusername = 'the username you have chosen is already taken'; $error = 1; } } if (strlen($user) < '5') { $usernameerror = 'the username is too short'; $error = 1; } if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) { $emailerror = 'the email address isnt a valid email address'; $error = 1; } if (strlen($password) < '9') { $errorpass = 'the password is too short it must be at least 8 characters'; $error = 1; } if ($error == "") { $pass = md5($password); mysql_query("INSERT INTO login (loguser, logpass, logname, logsurname, logaddress, logarea, logcounty, logpostcode, logtelephone, logni, logemail, logcompanyid, logaccess) VALUES ('$user', '$pass', '$name', '$surname', '$address', '$area', '$county', '$postcode', '$telephone', '$ni' '$email', '$companyid', '".$_POST['access']."')") or die (mysql_error()); header("Location: ../index.php"); } For some reason the script is passing over the $error, if it does pass over $error == "" then it should display why the error has occured, but I cant get it to work :/ any idea, is there any better way to do this validation.Thanks,kvarnerexpress Share this post Link to post Share on other sites
truefusion 3 Report post Posted September 11, 2005 Maybe replacing this: if ($error == "") { With:if ($error == NULL) {Might help? Share this post Link to post Share on other sites
SystemWisdom 0 Report post Posted September 12, 2005 Try this: while ($checking = mysql_fetch_array($check)){ $usr = $checking['loguser']; $mail = $checking['logemail']; $error = 0; if ($mail == $email){ $errormsg = "the email address you have chose is already taken"; $error = 1; } if ($usr == $user) { $errormsg= 'the username you have chosen is already taken'; $error = 1; } } if (strlen($user) < '5') { $errormsg= 'the username is too short'; $error = 1; } if (eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)) { $errormsg= 'the email address isnt a valid email address'; $error = 1; } if (strlen($password) < '9') { $errormsg= 'the password is too short it must be at least 8 characters'; $error = 1; } if ($error) { echo $errormsg; } else { $pass = md5($password); mysql_query("INSERT INTO login (loguser, logpass, logname, logsurname, logaddress, logarea, logcounty, logpostcode, logtelephone, logni, logemail, logcompanyid, logaccess) VALUES ('$user', '$pass', '$name', '$surname', '$address', '$area', '$county', '$postcode', '$telephone', '$ni' '$email', '$companyid', '".$_POST['access']."')") or die (mysql_error()); header("Location: ../index.php"); } Share this post Link to post Share on other sites
SystemWisdom 0 Report post Posted September 12, 2005 Oh, and you're missing a comma in youSQL statement here: '$ni' '$email' Sry for double post.. Share this post Link to post Share on other sites