sorry, i forgot to put php code.

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\login_test\register.php on line 152
line 152 is the last lne </form>

<?php
include("connect.php");

//grab submitted data
if(isset($_POST['submit']))
{
    //grab submitted data
    $firstname =  $_POST['firstname'];
    $lastname = $_POST['lastname'];
    $username = $_POST['username'];
    $password = $_POST['password'];
    $confirm_password = $_POST['confirm_password'];

    $dob_year = $_POST['dob_year'];
    $dob_month = $_POST['dob_month'];
    $dob_day = $_POST['dob_day'];
    $gender = $_POST['gender'];

    $reg_error = "";

    //check for empty fields
    if(empty($_POST['firstname']) || empty($_POST['lastname']) || empty($_POST['username']) || 
    empty($_POST['password']) || empty($_POST['confirm_password']) || empty($_POST['dob_year']) 
    || empty($_POST['dob_month']) || empty($_POST['dob_day']) || empty($_POST['gender']))
    {
        $reg_error .= "Missing field! Please fill in  all field!";
    }
    else 
    { 
        //check len of firstname, lastname, username
        if(strlen($firstname) > 20 || strlen($lastname) > 20 && strlen($username) > 20)
        {   
            $reg_error .= "Fistname, lastnmae and username must be no more than 25 characters!";
        }
        else
        {
            //check len of passwords
            if(strlen($password) > 25 || strlen($password) < 6)
            {
                $reg_error .= "Password must be between 6 and 25 characters!";
            }   
            else
            {
                //compare password
                if($password != $confirm_password)
                {
                    $reg_error .= "Password do not match!";
                }
                else
                {
                    //check for dob is number
                    if(!(is_numeric($dob_year) || is_numeric($dob_month) || is_numeric($dob_day)))
                    {
                        $reg_error .= "Date of birth must be in number form. For example, 1989/06/09";
                    }
                    else
                    {
                        //check value limit of dob
                        if(strlen($dob_year) > 4 || strlen($dob_month)>2 || strlen($dob_day)>2)
                        {
                            $reg_error .= "Date of birth year musb be 4 characters, month and day must be 2 characters.";
                        }
                        else
                        {
                            //check value of dob
                            if($dob_month > 12 || $dob_day > 31)
                            {
                                $reg_error .= "Date of birth month or day is bigger than expected!";
                            }
                            else
                            {
                                //check for gender
                                if($gender != "Male" && $gender != "Female")
                                {
                                    $reg_error .= "Gender must be Male or Female!";
                                }
                                else
                                {
                                    //check for existing user
                                    $query = mysql_query("Select * FROM user WHERE username = '$username'");        
                                    if(mysql_num_rows($query) >= 1)
                                    {
                                        $reg_error .= "That username is already taken";
                                    }
                                    else
                                    {
                                        //success
                                        $dob_db = "$dob_year-$dob_month-$dob_day";
                                        $password_db = $password;
                                        switch($gender)
                                        {
                                            case "Male";
                                                $gender_db = "M";
                                            break;
                                                case"Female";
                                            $gender_db = "F";
                                            break;
                                        }
                                        $register = mysql_query("INSERT INTO register VALUES('','$firstname','$lastname','$username','$password','$dob','$gender')");
                                        //change to header(LOCTION
                                        die("You have been registered! <a href='index.php'>Return</a> to login page");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }                                           
?>

<html>
<title>Register</title>
<head>
<link rel = "stylesheet" href = "css.css">
</head>
<body>
    <form action="register.php" method="post">
        <?php
        //print errors
        if(array_key_exists('reg_error', $_SESSION) && !empty($_SESSION['reg_error']))
        {
            echo $_SESSION['reg_error'];
            unset($_SESSION['reg_error']);
        }
        ?>
    Firstname: <input class = "text" type="text" name="firstname"><br>
    Lastname: <input class = "text" type="text" name="lastname"><br>
    Username: <input class = "text" type="text" name="username"><br>
    <!-- HINT -->
    <p class="hint">20 characters maximum (letters and numbers only)</p>
    Password: <input type="password" name="password"><br>
    <!-- HINT -->
    <p class="hint">20 characters maximum (letters and numbers only)</p>                  
    Confirm your password: <input type="password" name="confirm_password" size="30"><br>
    <!-- HINT -->
    <p class="hint">20 characters maximum (letters and numbers only)</p>
    Email: <input type="text" name="email"><br/>
    DOB:
        <input type='text' name='dob_year' maxlength='4' size='3' value='YYYY'> / 
        <input type='text' name='dob_month' maxlength='2' size='1' value='MM'> /
        <input type='text' name='dob_day' maxlength='2' size='1' value='DD'> <br/>
    Gender:
        <select name="gender">
             <option>Female</option>
            <option>Male</option>
         </select> 
    <input type="submit" value="Register">
    </form>
</body>
</html>
Member Avatar for diafol

Try changing this:

    }                                           
?>

TO this:

    }                                           
}
?>

The outside open brace seems to be misaligned with the outside closing brace, which suggests that one is missing.

i putted this code in between

        }
    }
    $_SESSION['reg_error'] = $reg_error;      
    header('Location: register.php');           
   ?>

and i got a error page saying:

This webpage has a redirect loop
The webpage at http://localhost/login_test/register.php has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

oh i see the problem

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.