How to send data to a server (apache /php & mysql) in Unity , example: Login system. github.com/herbou/Tuto_Unity_...
Пікірлер: 103
@helenawilsena58214 жыл бұрын
Great Hamza. I'm getting die heart fan day by day. You are the best KZbinr of unity Game dev. 💜💛💚💙❤ Love you n we support you
@herbou4 жыл бұрын
Thank you so much 😊.
@saifcode81252 жыл бұрын
*Thanks Hamza, you're a hero!* Followed your guide, it's impressive how well you fit all this information in 6minutes, you definitely make it look simple when it really isn't! Everything worked great after I reconfigured the variables and their names to fit my database! I do have a tiny request though, what if I want to also check whether this account is active or not? I have the field added in my database, but I'd like to know how to pass it to Unity and check there. If you could help me with that, it would be awesome and maybe others might also learn from it!
@divsyntax9720 Жыл бұрын
Earned yourself a new sub!! 😎😎 Thanks, dude!
@oscar26519584 жыл бұрын
thanks Hamza, nice video! Would you have a version using new UnityWebRequest ?
@smitsheth82753 жыл бұрын
How do i make this for my android device ? And skip the login scene if the user has logged in once ??
@rohanpereira70844 жыл бұрын
Awesome tutorials
@humblen01674 жыл бұрын
can you please make a tutorial for assest Bundel how I can load the texture as raw format, like this byte[] bytes = assetBundle.LoadAsset(id + ".bytes").bytes; File.WriteAllBytes(path, bytes);
@q4h4r264 жыл бұрын
Thanks for sharing ! also, may i ask how did you learn unity and coding in general? I'm looking for some resources.
@herbou4 жыл бұрын
Just by practicing more and more and trying to figure out how to do things by your self without help (just for few hours😂) . And the best place is unity's documentation and forums.
@rohanvaradkar11102 жыл бұрын
can game made in unity work with php laravel, and other backend frameworks like ruby on rails, python django etc. ?
@shahad23313 жыл бұрын
If i want add more info how can i do?
@khushal_khandelwal Жыл бұрын
If i create this then user data will save to server example i export game gplay store and then my user started playing after a few month i gave update then my user lose data or not
@user-qn2cf8pr9e9 ай бұрын
Hi , Hamza , Can you tell me how can add the unity/api in server not localhost
@ozan18784 жыл бұрын
Hello Hamza, is there any way to get html tag in php file to string c#. Example i will set user id, user gender to int id = ..... and string gender= ... You use Contains() but that way if multiple echo in php i had to use split function and etc. Is there any way to just get (14) 14 in this tag in php file
@herbou4 жыл бұрын
I have no idea what you mean. Give me more details .. and examples .. (files)
@danopalla3403 жыл бұрын
Hello. Can you make a register system? Thanks for your videos.
@julmardelima14342 жыл бұрын
will this work if I will build it to android platform?
@mistyjaveniar198911 ай бұрын
hello, just want to ask what apps did you use in php and sql?
@herbou11 ай бұрын
Wamp
@AnyasAkili Жыл бұрын
hello hamza, can we use the same code using mirror at unity to send data from database to a dedicated server because i am trying to do a multiplayer game software, but i don't know if your code is adequate?
@herbou Жыл бұрын
sorry I don't have any experience with multiplayer. I have no idea if this code will work with mirror too
@helenawilsena58214 жыл бұрын
Hamza can you make a unity touch screen swiping camera controller. Actually i have a joysticks but it have a buttons for control camera. But i need screen swiping for control camera. And Click to shooting or flight method. Please hamza make a video on it.
@machine0man3 жыл бұрын
Silent youtubers are nicee
@mohibkhan24923 жыл бұрын
Hello bro can you please do it with sql server?
@selcuknuray2 жыл бұрын
Teşekkür ederim / Thank you
@warzyl70904 жыл бұрын
Is it possible to host for free our database and our php files (not in local)? For example, I tryed "000webhost", but after 3 days they always send me a message saying that I didn't respect the terms of use...
@herbou4 жыл бұрын
Yes you can host it anywhere
@herbou4 жыл бұрын
But i think 000webhost has sleep time with free . And if it's working locally "localhost" then it will work any where else
@NHGeneral3 жыл бұрын
Hi Hamza Herbou, How can we connect to a server that not running in our PC? My case is the server running on Raspberry Pi, the setup is LAMP and it working well, from my PC, I can open phpmyadmin on Raspi in browser, but I don't know how to make it work with unity. I really need this to make a simple mobile app that making data transfer with Raspi server. Please help!
@herbou3 жыл бұрын
sorry man, i have no experience with Raspberry Pi
@NHGeneral3 жыл бұрын
@@herbou I did it, my app working well on mobile, connected to Raspi, but just on LAN, I still try to figure out how to translate the IP to WAN. Thank you for your reply.
@EmptySkySora3 жыл бұрын
video made in 2020 using the obsolete "www" system. Nice.
@endcraftable3 жыл бұрын
what do you mean?
@EmptySkySora3 жыл бұрын
@@endcraftable the system used in the video is obsolete. Google unitywebrequest for the new scripting method.
@natnaelghirma26173 жыл бұрын
One tip Hamza, instead of using string comparison (3:59) to check for errors, is it possible to check for error codes from the response, like 401 for wrong username/password or 500 for server error?
@herbou3 жыл бұрын
it's possible but i don't know how 😊
@natnaelghirma26173 жыл бұрын
@@herbou the server is simple if you use a framework. The hard part is you have to break apart the response text to get the error code on Unity.
@herbou3 жыл бұрын
i'm sure there is an answer somwhere 😊
@smitsheth82753 жыл бұрын
I am getting error 404, so where do i have to store the php files ??
@herbou3 жыл бұрын
i'm using Wamp server for testing . the files stored in: C://wamp/www/ create a folder inside www/ called "unityTest" , and add "login.php" inside of it. url is: localhost/unityTest/login.php
@smitsheth82753 жыл бұрын
@@herbou I did the same, but now inspite of entering the correct username and password, it keeps displaying "Invalid username or password"
@shahad23313 жыл бұрын
Is this way work when i want to do an android app and save users info?
@herbou3 жыл бұрын
you have to buy a hosting to host your server (php) & DB somewhere online . i can't help you on this topic. kzbin.info/www/bejne/ZqvXhY1-iKite9k and sure you can add more info the same way i added email & password
@niranjanraje71603 жыл бұрын
We can do the same using nodejs as well right instead of php...?
@herbou3 жыл бұрын
yes
@emanuelcordovamontiel10173 жыл бұрын
How to save the user's session? Because when an user come back to the application it will enter its credentials again.
@herbou3 жыл бұрын
PlayerPrefs.SetInt("isLoggedIn",1); and in the start : if (PlayerPrefs.GetInt("isLoggedIn",0)==0) Login(); else //skip login (already logged in)
@amanirahman48252 жыл бұрын
@@herbou may i know where to put this code?
@fukukyun782 жыл бұрын
Downloaded your git project to get a better idea... It's broken lol, the "Server" script is missing, therefor when i download it, I have to fill in all the values manually. I don't understand where the URL comes from, where do you find the URL? Where is this php file you're just randomly editing? lol
@CREATIVNICK2 жыл бұрын
Great tuto!but i cant connect to the server! show 404 not found error
@jesper993 жыл бұрын
if i click the login button, it goes to the next screen. Even if i enter the wrong info.
@herbou3 жыл бұрын
that's impossible
@ahmedelgendy36163 жыл бұрын
This is awesome 👌👏 What about Android phones ?
@rihabbelhiba58514 жыл бұрын
hello thanks for the video but what if i want to make it work on wifi (remote) what do i need ??
@herbou4 жыл бұрын
You mean a local server? if so you can use localhost . But instead of word localhost in url .use server IP (computer ip) .then you can login from any other device if they are in same network
@rihabbelhiba58514 жыл бұрын
@@herbou after i finish the build of my app on my phone and i want to run it using my server (localhost) how?
@herbou4 жыл бұрын
Connect the mobile and computer (or same wifi) and in the url write computerIP/login... instead of localhost. Go to the mobile navigator and test the URL before building the app
Thank for the best tutorial bro! I have some problem when build to android it cant be success register or login , before that in unity every oky. why? can u please help me , im new unity here . thank you a lot! I wish I got your reply and help!
@herbou3 жыл бұрын
if you're using a localhost it won't work in your mobile.
@pranavmohite85812 жыл бұрын
Which IDE are u using for php
@herbou2 жыл бұрын
sublime text
@cotafei2 жыл бұрын
will there be a continuation with registration?
@herbou2 жыл бұрын
I'm afraid not. because it's the same logic, you just need the SQL code to add users to the database
@monchiquediscovery3 жыл бұрын
Hi Tank You For The Great Tutorial , i have a question wish encriptation you use in the password?
@herbou3 жыл бұрын
sha1
@revotiva4 жыл бұрын
can i use this for mobile?
@herbou4 жыл бұрын
Yes of course
@SKJagan-dh2ft3 жыл бұрын
I want my assets and user login to be online, can you make a detailed video on how to do this using google cloud services!
@herbou3 жыл бұрын
I didn't do that before, but I guess you need to search for asset bundles Like this one : kzbin.info/www/bejne/anzCdGSQiqiKedE
@SKJagan-dh2ft3 жыл бұрын
@@herbou thank you for the video link, but its only about asset bundles. I tried to use the firebase SDK in unity for login, which is showing errors. It will be great if you make a video on it as others one are outdated or buggy videos.
@herbou3 жыл бұрын
I didn't use firebase before but maybe in a future video , sorry 🙏
@SKJagan-dh2ft3 жыл бұрын
@@herbou even I'm not bound to it, can you suggest any other platform than firebase!
@tineswaranchandran89924 жыл бұрын
if you enter username and password, it came out 'invalid username or password!'. Try remove sha1 that used for password encryption
@herbou4 жыл бұрын
I used Sha1 encryption in the Database .that's why it works for me.
can you show me the users passwords in the database??
@kevincranfield24713 жыл бұрын
im the same inserting correct username and password my passwords are encrypted in table, but i have tried to convert to unity request. IEnumerator Login() { Debug.Log("Updating Records"); form = new WWWForm(); form.AddField ("username", username.text); form.AddField("password", password.text); UnityWebRequest w = UnityWebRequest.Post(url, form); yield return w.SendWebRequest(); ; if(w.error != null) { errormessages.text = "404 not found"; } else { if (w.isDone) { errormessages.text = "invalid usrname or password!"; } else { //Open welcome panel welcomePanel.SetActive(true); user.text = username.text; } } loginButton.interactable = true; w.Dispose(); }
@saifgames24684 жыл бұрын
Amazing tutorial, i'm using binary saving data in my game how can i send it to a server ?
@herbou4 жыл бұрын
simple text data?
@saifgames24684 жыл бұрын
@@herbou binary data
@herbou4 жыл бұрын
But they are simple text data during the game?
@herbou4 жыл бұрын
If true the simply send to server before saving in files as binary
@saifgames24684 жыл бұрын
@@herbou [Serializable] class GameData { private bool isGameStartedFirstTime; private bool isMusicOn; private bool doubleCoins; private int selectedPlayer; private int selectedWeapon; private int coins; private int highScore; private bool[] players; private bool[] levels; private bool[] weapons; private bool[] achievements; private bool[] collectedItems; public void setDoubleCoins(bool doubleCoins) { this.doubleCoins = doubleCoins; } public bool getDoubleCoins() { return this.doubleCoins; } public void setIsGameStartedFirstTime(bool isGameStartedFirstTime) { this.isGameStartedFirstTime = isGameStartedFirstTime; } public bool getIsGameStartedFirstTime() { return this.isGameStartedFirstTime; } public void setIsMusicOn(bool isMusicOn) { this.isMusicOn = isMusicOn; } public bool getIsMusicOn() { return this.isMusicOn; } public void setSelectedPlayer(int selectedPlayer) { this.selectedPlayer = selectedPlayer; } public int getSelectedPlayer() { return this.selectedPlayer; } public void setSelectedWeapon(int selectedWeapon) { this.selectedWeapon = selectedWeapon; } public int getSelectedWeapon() { return this.selectedWeapon; } public void setCoins(int coins) { this.coins = coins; } public int getCoins() { return this.coins; } public void setHighScore(int highScore) { this.highScore = highScore; } public int getHighScore() { return this.highScore; } public void setPlayers(bool[] players) { this.players = players; } public bool[] getPlayers() { return this.players; } public void setLevels(bool[] levels) { this.levels = levels; } public bool[] getLevels() { return this.levels; } public void setWeapons(bool[] weapons) { this.weapons = weapons; } public bool[] getWeapons() { return this.weapons; } public void setAchievements(bool[] achievements) { this.achievements = achievements; } public bool[] getAchievements() { return this.achievements; } public void setCollectedItems(bool[] collectedItems) { this.collectedItems = collectedItems; } public bool[] getCollectedItems() { return this.collectedItems; } } // game data
@sergiocamoleze11562 жыл бұрын
The password needs to be encrypted in unity3d to not be transported over the internet unencrypted
@Benzitczo Жыл бұрын
missing need REGISTER
@danielspriggan29873 жыл бұрын
and...registry?
@herbou3 жыл бұрын
same steps, you need just some change in the server side (php)