I've created a form for the user to update the registration data. The "old" user data is stored in session variables that populate the form as soon as the user clicks refresh registration. The problem is that writing the data to the database is considered the data filled in by the session variables instead of the new data entered on the form. Can you help me solve this? Thank you. Here is the C # code:
protected void btnEnviar_Click(object sender, EventArgs e)
{
MySqlConnection conexao = ConexaoDB.GetConexao();
try
{
string comandoSQL = "UPDATE MA_USERS SET " +
"nomecliente = '{1}', " +
"facebook = '{2}', " +
"website = '{3}', " +
"cidade = '{4}', " +
"estado = '{5}', " +
"emailprofissional = '{6}' " +
"where idcliente= '{0}'";
comandoSQL = string.Format(comandoSQL, txtUsuario.Text,
txtNome.Text, txtFacebook.Text, txtWebsite.Text, txtLocal.Text, ddlEstado.Text, txtEmail.Text);
Response.Write("<script>alert('" +comandoSQL+ "');</script>");
MySqlCommand comando = new MySqlCommand(comandoSQL, conexao);
comando.ExecuteNonQuery();
}
finally
{
conexao.Close();
}
}
}
And the .aspx form code:
<div class="col-xs-8 col-xs-offset-2 form-div">
<form id="form1" runat="server">
<div style="padding: 10px; padding-top: 50px; width: 400px; margin-left: auto; margin-right: auto; background-color: #f6f3f3;">
<h3>Update your informations:</h3>
<p>Name:</p>
<asp:TextBox ID="txtNome" runat="server" CssClass="textobox" Width="382px"></asp:TextBox>
<p>Facebook:</p>
<asp:TextBox ID="txtFacebook" runat="server" CssClass="textobox" Width="182px"></asp:TextBox>
<br />
<p>Website:</p>
<asp:TextBox ID="txtWebsite" runat="server" CssClass="textobox" Width="382px"></asp:TextBox>
<p>Professional E-mail:</p>
<asp:TextBox ID="txtEmail" runat="server" CssClass="textobox" Width="382px"></asp:TextBox>
<p>City:</p>
<asp:TextBox ID="txtLocal" runat="server" CssClass="textobox" Width="262px"></asp:TextBox>
<p>State:</p>
<asp:DropDownList ID="ddlEstado" runat="server"></asp:DropDownList>
<br /><br /><br />
<asp:Button ID="btnEnviar" runat="server" Text="Send" OnClick="btnEnviar_Click" />
<br />
<asp:Label ID="lblErros" runat="server"></asp:Label>
<asp:TextBox ID="txtUsuario" runat="server" Visible="False"></asp:TextBox>
</div>
</form>
</div>