When I send UUID with android retrofit using post and store it to MySQL database I am getting different value, it is shorten and converted to numbers. Is there anything I have to do when I receive the UUID in PHP or when I store it to MySQL database table?
This is the UUID generated in my android application:
7cbb95ec-2de6-42a4-bd54-5a18b392ca03
and when it is stored into the user table it become like this numbers:
795-26-424-54-51839203
Please can someone explain why this happening and how to fix?
Api interface
@FormUrlEncoded
@POST("insertdata.php")
Call<ResponseBody>insertdata(
@Field("userid")String userid,
@Field("articleid")int articleid);
Php insertdata.php
if (isset($_POST['userid'])) {
$userid = filter_input(INPUT_POST, 'userid', FILTER_SANITIZE_NUMBER_INT);
} else {
die();
}
It's not a numerical value, so don't filter it like it is. You're deleting the non-numerical characters. Don't filter_input
, just leave it alone.
For SQL injection issues, as always, use prepared statements with placeholder values .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.