When the database server mode is not set to Strict, invalid and out of range values get truncated/cast to the nearest valid value for a columnâs data type.
You probably have some non-printing/white-space characters as part of the values. Using var_dump() on the variables helps identify this type of problem because it shows the length of the values.
You will most likely need to post all your form and form processing code for anyone here to be able to help with the problem.
You need to use a prepared query to prevent any sql special characters in a value from being able to break the sql query syntax, which is how sql injection is accomplished.
Maybe you username and email contains some special chars. Thatâs why you should use prepared statements.
Also you never ever should store a password uncrypted or hashed in a database. This is an offend to all your users.
Remember most user reuse their passwords. So if someone will register on your site, his password, which he might have used on many other sites, is readable for everyone with access to your database. Letâs say you have your database on a hosting service, normally many many administrating people from this company are able to read this.
All all the fiels are updated (their values change) but not Username and Email: Those the values remain the same. Not even cleared like with an empty variableâŚ
Until you tell or show us the actual result you are getting, what the expected result should be, and what is wrong with the result, we cannot help you. We are not sitting right next to you. Everything you see that looks correct, could be clues that would help us.
Going to take a guess. Since you are wrongly getting the id of the row matching the submitted username (you should be getting the id from your login session variable), and your username and email columns are not defined as unique indexes, you likely have more than one row of data for the same username value, and you are looking at the wrong row of data and it doesnât look like it got updated.
Another possibility since you are using ajax, since you havenât posted the form code for, is two requests are being made, the first one updates the data to the expected values, but the second one updates them back to the previous values.
If you havenât set the character set to match your database tables when you make the database connection (which is rarely done), you could be getting a character conversion occurring over the connection.