Why is my not(!) unexpected?

This question already has an answer here:

  • PHP parse/syntax errors; and how to solve them? 13 answers

  • The lines below:

     if(strlen($username) !<13){
         if(strlen($password) !<17){
    

    are not valid. They should use >=. eg

     if(strlen($username) >= 13){
         if(strlen($password) >= 17){
    

    even then, I'm pretty sure you wanted to write

     if(strlen($username) <= 13){
         if(strlen($password) <= 17){
    

    as your error messages state the rules for your username and password!

    I'm not sure I've seen any C derivative language use !< and !>

    ADDENDUM: You're also missing upper bound checks on email length (there is one on the wikipedia page here).

    You should consider writing a validator function, decomposing those nasty nested ifs which is really difficult code to maintain.

    As a starter for 10:

       if($password != $confirmpass){
            echo ("Your passwords do not match");
        return false;
       }
    
       // what about weird characters?
       if (empty($username) || strlen($username) < 3 || strlen($username) > 13) {
            echo "Your username must be between 3 and 13 characters.";
        return false;
       }
    
    
       // what about weird characters?
       if (empty($password) || strlen($password) < 3 || strlen($password) > 17) {
            echo "Your password must be between 3 and 17 characters.";
        return false;
       }
    
    
       // you'll want some kind of regex to validate that the email is well formed
       if (empty($email) || strlen($email) < 3 || strlen($email) > 254) {
            echo "Your email must be between 3 and 254 characters.";
        return false;
       }
    
       $sql ="INSERT INTO users(user,pass,email) VALUES('".$username."','".md5($password)."','".$email."')";
       mysql_query($sql);
       header('Location: Login.php');
    

    Your syntax is incorrect, you are trying to negate an comparison operator but this is not syntax in PHP. The only valid forms of > and < are:

    >= or <=

    链接地址: http://www.djcxy.com/p/69876.html

    上一篇: 在c ++中存储和打印10+数字整数

    下一篇: 为什么我的不是(!)意外?