now this hdb post uh you already know that about okay that is this response is basically we have to check either we are connected successfully with the API uh that is with the help of our API either we are our flutter application is connected successfully to the server or not that is either we are access accessing the signup. php code successfully or not with the help of our API so that response will come uh using inside this variable r s so we have to check either our API is working fine or not just like as I told you we have done this in the validating email when we were validating the email the same thing we have done here okay that is we will check that is uh either the repi API is connected successfully or not either the response is uh going and receiving from the server or not okay so we in simple words I have already written this comment that is from flutter app the connection with API to service if it is successful then it will uh bring us back the 200 Response Code status code okay so you already know that so now we can simply say here that is if response do status quote if this is 200 it means the connection is uh successful API is working successfully and then the result will come which we can decode Jon decode response. body and we will assign that to response body and this time this is of response body of sign up that is signup.
php file okay that's why I'm using the proper name so if that uh response body response body of sign up if that contains the key name let me show to you that is our signup. php if that contain the key name success that is if the sign up is executed successfully and the user record is saved successfully so you know that in case of uh that is if the query is executed successfully that is if the record is saved successfully to the datab Bas then to the key name success we assign the value true otherwise if any error occur that is the user record is not saved successfully then in that case to the key value to the key success we assign the value false okay so success key will have two values it will be either true or it will be false so success okay the same key name we can say if the response body that is this response okay so if you if it is true if it is equals to true then I have already told you guys earlier that is you can also further explain it like this okay it means the same that is if the response board is Success if the success key value is equals to true then we will display a message to the user that is flutter toast. show toast we will say that uh sign up successfully or registered successfully sign up successfully or you can write like congratulations sign up you are sign up successfully just like this otherwise else that is if any error occur then in that case we will say error record error occurred try again just like this and in case if any exception occur then we have to uh basically display the the exception message that is the error message so we can say e e do to string and if you want you can display this also in a toast message letter toast do short toost e.
2 string this e will basically show us the error message if any error occur that is what error is going on okay similarly in case of validating email we have also a catch so if any error occur we want to display that just like this so what we have done now let me just explain this code again first of all as I told you at the start of the video that is when we want to save any record to the mySQL database then we want to we must convert our user data or any data to the Json format so in order to convert our data to the Json format for that purpose we create cre at our user user model class okay and we just implement this code here now how it is working that is first of all to our user model class we pass the uh values to the required attributes here which is receiving inside here okay so then uh we communicate with the uh server with the help of our API for the purpose of registration okay that is signup signup. php so with the help of our API we communicate with the server that is we want to execute our signup. php backend code that is we want to save the new user record to the mySQL database so we communicate with the server and we pass the data to our signup uh.
PHP that is this one okay signup.