I am trying to make a website.
After I log in, there is an option for me to “edit user info”. In my EditUserInfo.aspx, users can change their password and date of birth. But the problem is, after they entered their password and DOB, how can I find their username in the database and update the password and DOB?
Here is the code for my editUserInfo function
public static bool EditUserInfo(string strCookieName, string password)
{
string query = "UPDATE usertb SET password = '" + password + "' WHERE username = '" + Name + "'";
accessDB dbaccess = new accessDB();
return dbaccess.saveData(query);
}
I tried to use cookie following the Microsoft guide, but it is not working. and I also tried to use the Response.Redirect(EditUserInfo.aspx?Name=Username)
which the Username is from the textbox (txtUsername.text) but also seems not working.
So I wonder if anyone can offer me the correct syntax or any idea to make it work? Thanks a lot
When the user got to that form have you set up a session for them?
You can use session like this:
Cookies:
If the user got to the edit form they should have logged in already. So you could store their userid in a session variable. Then when connecting to the database do a
TryParseon the session variable to update the correct record.