Session state with 2 buttons

Hi everyone,

I am building an app that has the following:

  1. User text input
  2. Submit button
  3. On pressing submit button, the app gives some output based on input
  4. After the output, the app gives the option for some feedback with another submit button
  5. On pressing button #2, the feedback gets stored in a database

Since it has 2 submit buttons, was trying to add session_state to it. Have tried multiple things and the closest to what I want was this:

usr = st.text_input("Enter a query")
if st.button("Show Results"):
    st.session_state["feedback"] = ""
    st.session_state["state"] = True
##perform some operation
if st.session_state["state"]:
    st.session_state["feedback"] = st.text_area("Pls give feedback.")
    if st.button("Submit response"):
        ##store in database

The issue is that it displays the text area asking for feedback immediately and does not wait for running the operation based on user query. Have tried setting session_state[“state”] to False but that does not solve the problem. Any help on this would be appreciated!