# Build a Salon Appointment Scheduler

**URL:** <https://forum.freecodecamp.org/t/build-a-salon-appointment-scheduler/800447>\
**Category:** Curriculum Help\
**Tags:** sql, bash, backend-development\
**Created:** [September 17, 2026, 8:57pm UTC](https://forum.freecodecamp.org/t/build-a-salon-appointment-scheduler/800447 "2026-09-17T20:57:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucas-rodrigues20](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucas-rodrigues20/32/162024_2.png) [@lucas-rodrigues20](https://forum.freecodecamp.org/u/lucas-rodrigues20)\
**Post date:** [September 17, 2026, 8:57pm UTC](https://forum.freecodecamp.org/t/build-a-salon-appointment-scheduler/800447/1 "2026-09-17T20:57:53Z")

</div>

## Tell us what’s happening:

Hello!

So, I made the `salon.sh` script and all tasks passes but the following two:

- You can create a row in the `appointments` table by running your script and entering `1`, `555-555-5555`, `Fabio`, `10:30` at each request for input if that phone number isn’t in the `customers` table. The row should have the `customer_id` for that customer, and the `service_id` for the service entered
- You can create another row in the `appointments` table by running your script and entering `2`, `555-555-5555`, `11am` at each request for input if that phone number is already in the `customers` table. The row should have the `customer_id` for that customer, and the `service_id` for the service entered

 ![Captura de tela 2026-09-17 175430](https://global.discourse-cdn.com/freecodecamp/original/4X/3/9/8/3982c28a0f600f9f4ae0904c4f506eb8d2cd2387.png)

Running these steps manually works just fine.

If anyone could give some help.

## Your code so far

```bash
#! /bin/bash

PSQL="psql -X --username=freecodecamp --dbname=salon --tuples-only -c"

echo -e "\n ~~~~~MY SALON~~~~~ \n"

echo -e "Welcome to My Salon, how can I help you?\n"

MAIN_MENU() {
  if [[$1]]
  then
    echo -e "\n$1"
  fi

  SERVICES_AVAILABLE=$($PSQL "SELECT service_id, name FROM services;")

  echo "$SERVICES_AVAILABLE" | while read SERVICE_ID BAR SERVICE_NAME
  do
    echo "$SERVICE_ID) $SERVICE_NAME"
  done

  read SERVICE_ID_SELECTED

  SERVICE_NAME_SELECTED=$($PSQL "SELECT name FROM services WHERE service_id = $SERVICE_ID_SELECTED;")

  if [[-z $SERVICE_NAME_SELECTED]]
  then
    MAIN_MENU "I could not find that service. What would you like today?"
  else
    
    # get customer info
    echo -e "\nWhat's your phone number?"
    read CUSTOMER_PHONE

    CUSTOMER_NAME=$($PSQL "SELECT name FROM customers WHERE phone = '$CUSTOMER_PHONE';")

    # if customer doesn't exist
    if [[-z $CUSTOMER_NAME]]
    then
      # get new customer name
      echo -e "\nI don't have a record for that phone number, what's your name?"
      read CUSTOMER_NAME

      # insert new customer
      INSERT_CUSTOMER_RESULT=$($PSQL "INSERT INTO customers (name, phone) VALUES ('$CUSTOMER_NAME', '$CUSTOMER_PHONE');")
    fi

    echo -e "\nWhat time would you like your $(echo $SERVICE_NAME_SELECTED | sed -E 's/^ *| *$//g'), $(echo $CUSTOMER_NAME | sed -E 's/^ *| *$//g')?"
    read SERVICE_TIME

    CUSTOMER_ID=$($PSQL "SELECT customer_id FROM customers WHERE phone = '$CUSTOMER_PHONE';")

    INSERT_APPOINTMENT_RESULT=$($PSQL "INSERT INTO appointments (customer_id, service_id, time) VALUES ($CUSTOMER_ID, $SERVICE_ID_SELECTED, '$SERVICE_TIME');")

    echo -e "\nI have put you down for a $(echo $SERVICE_NAME_SELECTED | sed -E 's/^ *| *$//g') at $(echo $SERVICE_TIME | sed -E 's/^ *| *$//g'), $(echo $CUSTOMER_NAME | sed -E 's/^ *| *$//g')."

  fi
  
}

MAIN_MENU

```

## 

Lesson URL ([https://www.freecodecamp.org/learn/relational-databases-v9/lab-salon-appointment-scheduler/lab-salon-appointment-scheduler](https://www.freecodecamp.org/learn/relational-databases-v9/lab-salon-appointment-scheduler/lab-salon-appointment-scheduler))

---

<div class="post-metadata">

**Author:** ![lucas-rodrigues20](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lucas-rodrigues20/32/162024_2.png) [@lucas-rodrigues20](https://forum.freecodecamp.org/u/lucas-rodrigues20)\
**Post date:** [September 18, 2026, 1:50am UTC](https://forum.freecodecamp.org/t/build-a-salon-appointment-scheduler/800447/2 "2026-09-18T01:50:22Z")

</div>

I just found out that the `time` column in the `appointments` table was somehow too short for the values used in those cases.

Increasing the column size fixed the problem.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [September 20, 2026, 1:50am UTC](https://forum.freecodecamp.org/t/build-a-salon-appointment-scheduler/800447/3 "2026-09-20T01:50:59Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
