what is wrong with my code
int main(void) {
    char user_id[MAXLINE];
    char password[MAXLINE];

    /* The user will type in a user name on one line followed by a password
       on the next.
       DO NOT add any prompts.  The only output of this program will be one
           of the messages defined above.
       Please read the comments in validate carefully
     */

    if(fgets(user_id, MAXLINE, stdin) == NULL) {
        perror("fgets");
        exit(1);
    }
    if(fgets(password, MAXLINE, stdin) == NULL) {
        perror("fgets");
        exit(1);
    }

    // Check for exceeded length
    if (strlen(user_id) > 10 || strlen(password) > 10) {
        printf(NO_USER);
    } else {
        int fd[2];
        int r;

        // Create the pipe
        if ((pipe(fd) == -1)) {
            perror("pipe");
            exit(1);
        }

        if ((r = fork()) > 0) {  // If parent process
            int status;

            if ((close(fd[0])) == -1) {  // Close the read
                perror("close");
            }

            if (write(fd[1], user_id, strlen(user_id) + 1) == -1) {  // Write the user id
                perror("write to pipe");
            }
                        write(fd[1], "\n", 1); // Write the newline

            if (write(fd[1], password, strlen(password) + 1) == -1) { // Write the password
                perror("write to pipe");
            }

            if ((close(fd[1])) == -1) { // Close the write
                perror("close");
            }

            wait(&status); // wait
            printf("%d", WEXITSTATUS(status));
            if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { // If it is equal to 0
                printf(SUCCESS);
            } else {
                printf(INVALID);
            }

        } else if (r == 0) {  // If child process
            if ((close(fd[1])) == -1) {  // Close the write
                perror("close");
            }

            if ((dup2(fd[0], fileno(stdin))) == -1) { // So it can read from pipe
                perror("dup2");
                exit(1);
            }

            if ((close(fd[0])) == -1) {
                perror("close");
            }

            execl("./validate", "validate", user_id, password, NULL); // Validate


        } else {
            perror("fork");  // Check for failed fork
            exit(1);
        }
    }
    return 0;
}
