User login validation problem

Discussion in 'PHP' started by -RiE-, Jul 3, 2008.

  1. #1
    Hi,

    I've problem with user login validation.

    This is my code:
                                    } else {
                                        // submitted
                                        // initialize array to hold validation errors
                                        $errorList = array();
                                        // check if required input is present
                                        if (!isset($_POST['username']) || trim($_POST['username']) == "") 
                                        {
                                            $errorList[] = "ERROR: Missing value username";
                                        }
                                        // check if input is of correct length
                                        if (strlen($_POST['password']) < 6) 
                                        {
                                            $errorList[] = "ERROR: Incorrect length for value password";
                                        }
                                        // check if username is alphanumeric
                                        if (preg_match("/^[a-z0-9]*$/i", $_POST['username'])
                                        { // LINE 109
                                            $errorList[] = "ERROR: Username must be alphanumeric";
                                        }
                                        // check to see if any validation errors occurred
                                        if (sizeof($errorList) > 0) 
                                        {
                                            // if errors occurred
                                            // display error list
                                            // and terminate script processing
                                            echo "Please review and correct the following errors: <br />";
                                            foreach ($errorList as $e) 
                                            {
                                                echo "$e <br />";
                                            }
                                        } 
                                        else 
                                        {
                                            // and so on
                                        }
                                    }  
    PHP:
    I got error code: Parse error: syntax error, unexpected '{' in **\sidebar.php on line 109

    can you help me?
     
    -RiE-, Jul 3, 2008 IP
  2. wowla_123

    wowla_123 Peon

    Messages:
    147
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please tell which is the line 109?
     
    wowla_123, Jul 3, 2008 IP
  3. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #3
    you need to post sidebar.php

    Also tell which is line 109

    then only we can help you out

    Regards

    Alex
     
    kmap, Jul 3, 2008 IP
  4. -RiE-

    -RiE- Peon

    Messages:
    450
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have attached my sidebar and also the line 109.

    It is located in
    
    // check if username is alphanumeric
                                        if (preg_match("/^[a-z0-9]*$/i", $_POST['username'])
                                        { // LINE 109
    
    PHP:
     
    -RiE-, Jul 3, 2008 IP
  5. clarky_y2k3

    clarky_y2k3 Well-Known Member

    Messages:
    114
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    108
    #5
    You are missing a closing parenthesis:
    
    if (preg_match("/^[a-z0-9]*$/i", $_POST['username']))
    
    PHP:
     
    clarky_y2k3, Jul 3, 2008 IP
  6. -RiE-

    -RiE- Peon

    Messages:
    450
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ^
    oh that's it. thanks!
     
    -RiE-, Jul 4, 2008 IP