Form Variables values not being saved

My form variable values disappear. I have the following code to update a new user’s details into a text file:

def SignUp():
st.title(“New User:”)
with st.form(key = “SgFrm”):
unme = st.text_input("User Name: ")
pwd = st.text_input("Password: ")
firm = st.text_input("Company: ")
email = st.text_input("Email Address: ")
vfn1 = st.text_input("Data File Name1: ")
vfn2 = st.text_input("Data File Name2: ")

    sbtn = st.form_submit_button("Submit User Information")
    if sbtn:
        st.sidebar.write(sbtn)
        tfl = open("./userconfig.txt", "a")
        tfl.write(f"\n{unme},{pwd},{firm},{email},{vfn1},{vfn2}")
        tfl.close()

snupbtn = st.sidebar.button(“Sign Up”)
if snupbtn:
SignUp()

lginbtn = st.sidebar.button(“Login”)
if lginbtn:
pass

How do I stop the form variables from reinitializing?

I am also facing similar issue the input field values are not getting passed to next function.

Hi @Pradeep_Inani , please check out session state in the Streamlit documentation.

Cheers