I'm having this problem where I have a registration form and I am using PHP and MySQL. The problem is that even when all the data is valid it wont enter the information into the database. I know the database is connected because I can use it with the login part of my website. I think it is the problem with the email and username cross check against the database but I am not sure. Is the positioning of the curly braces or alot more complex?
<?php
  include_once('db.php');
  $name = mysql_real_escape_string( $_POST["name"] );
  $username = mysql_real_escape_string( ($_POST["username"]) );
  $password = mysql_real_escape_string( md5 ($_POST["password"]) );
  $repeatpassword = mysql_real_escape_string( $_POST['repeatpassword'] );
  $email = mysql_real_escape_string( $_POST["email"] );
  $confirmemail = mysql_real_escape_string( $_POST['confirmemail'] );
  // the below if statement is for when the user does NOT have JS enabled in            their browser
  if(empty($name) || empty($username) || empty($password) || empty($email)){
    echo "(*) indicate that the fields are mandatory.";
    exit();
  }
  if($email == $confirmemail){
    exit();
  }else{
    echo "Your Email address does not match.";
  }
  if($email == $repeatpassword){
    exit();
  }else{
    echo "Your Passwords do not match.";
    exit();
}
  $res = mysql_query("SELECT username FROM users WHERE username='$username'");
  $row = mysql_fetch_row($res);
  $res1 = mysql_query("SELECT email FROM users WHERE email='$email'");
  $row1 = mysql_fetch_row($res1);
  if( $row > 0 ){
    echo nl2br("The username $username is already in use");
  }else{
        if( $row1 > 0 ){
            echo nl2br("the email address $email is already in use");
        }else{
        $sql = "INSERT INTO users VALUES('','$name',  '$username', '$password', '$email')";
        if( mysql_query($sql) ){
            echo "Inserted Successfully";
        }else{
        echo "Insertion Failed";
        }
    }  
}
?>
 
     
    