When you have an INSERT statement without columns, the order of columns will be expected to match the table schema.
Based on that, let's re-examine your snippet:
$result = mysqli_query($conn, "insert into user values('".$username."', sha1('".$password."'), '".$email."')");
if (!$result) {
throw new Exception('Could not register to DB.');
}
According to this, you're inserting a username, then a password, then an email. However, your table schema defines a username first, then an email, then the password.
Based on that, let's use the below snippet instead. Note that this utilizes prepared statements, which prevents SQL injection attacks.
$query = "INSERT INTO user (username, passwd, email) VALUES (?,?,?)";
if ($stmt = mysqli_prepare($conn, $query)) {
/* bind parameters for markers */
mysqli_stmt_bind_param($stmt, "sss", $username, sha1($password), $email);
/* execute query */
mysqli_stmt_execute($stmt);
/* close statement */
mysqli_stmt_close($stmt);
}
An additional problem: your password field in the database is much too short (17 characters). An SHA-128-hashed password is exactly 40 characters, and to use the password_* methods, you'd need at least 60 characters. I'd advise simply setting the password field to 255 characters.
Please also keep Jay Blanchard's comment in mind to use the password_* family of functions. instead of hashing a password with SHA1.