Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Validation Error No Insert

Recommended Posts

im having some trouble with this

PHP 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

Maybe replacing this:

if ($error == "") {

With:
if ($error == NULL) {
Might help?

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.