Unity Send data to a SERVER (Login System) , PHP & MYSQL

  Рет қаралды 50,900

Hamza Herbou

Hamza Herbou

4 жыл бұрын

How to send data to a server (apache /php & mysql) in Unity , example: Login system.
github.com/herbou/Tuto_Unity_...

Пікірлер: 103
@helenawilsena5821
@helenawilsena5821 4 жыл бұрын
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
@herbou
@herbou 4 жыл бұрын
Thank you so much 😊.
@saifcode8125
@saifcode8125 2 жыл бұрын
*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
@divsyntax9720 Жыл бұрын
Earned yourself a new sub!! 😎😎 Thanks, dude!
@oscar2651958
@oscar2651958 4 жыл бұрын
thanks Hamza, nice video! Would you have a version using new UnityWebRequest ?
@smitsheth8275
@smitsheth8275 3 жыл бұрын
How do i make this for my android device ? And skip the login scene if the user has logged in once ??
@rohanpereira7084
@rohanpereira7084 4 жыл бұрын
Awesome tutorials
@humblen0167
@humblen0167 4 жыл бұрын
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);
@q4h4r26
@q4h4r26 4 жыл бұрын
Thanks for sharing ! also, may i ask how did you learn unity and coding in general? I'm looking for some resources.
@herbou
@herbou 4 жыл бұрын
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.
@rohanvaradkar1110
@rohanvaradkar1110 2 жыл бұрын
can game made in unity work with php laravel, and other backend frameworks like ruby on rails, python django etc. ?
@shahad2331
@shahad2331 3 жыл бұрын
If i want add more info how can i do?
@khushal_khandelwal
@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-qn2cf8pr9e
@user-qn2cf8pr9e 9 ай бұрын
Hi , Hamza , Can you tell me how can add the unity/api in server not localhost
@ozan1878
@ozan1878 4 жыл бұрын
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
@herbou
@herbou 4 жыл бұрын
I have no idea what you mean. Give me more details .. and examples .. (files)
@danopalla340
@danopalla340 3 жыл бұрын
Hello. Can you make a register system? Thanks for your videos.
@julmardelima1434
@julmardelima1434 2 жыл бұрын
will this work if I will build it to android platform?
@mistyjaveniar1989
@mistyjaveniar1989 11 ай бұрын
hello, just want to ask what apps did you use in php and sql?
@herbou
@herbou 11 ай бұрын
Wamp
@AnyasAkili
@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
@herbou Жыл бұрын
sorry I don't have any experience with multiplayer. I have no idea if this code will work with mirror too
@helenawilsena5821
@helenawilsena5821 4 жыл бұрын
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.
@machine0man
@machine0man 3 жыл бұрын
Silent youtubers are nicee
@mohibkhan2492
@mohibkhan2492 3 жыл бұрын
Hello bro can you please do it with sql server?
@selcuknuray
@selcuknuray 2 жыл бұрын
Teşekkür ederim / Thank you
@warzyl7090
@warzyl7090 4 жыл бұрын
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...
@herbou
@herbou 4 жыл бұрын
Yes you can host it anywhere
@herbou
@herbou 4 жыл бұрын
But i think 000webhost has sleep time with free . And if it's working locally "localhost" then it will work any where else
@NHGeneral
@NHGeneral 3 жыл бұрын
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!
@herbou
@herbou 3 жыл бұрын
sorry man, i have no experience with Raspberry Pi
@NHGeneral
@NHGeneral 3 жыл бұрын
@@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.
@EmptySkySora
@EmptySkySora 3 жыл бұрын
video made in 2020 using the obsolete "www" system. Nice.
@endcraftable
@endcraftable 3 жыл бұрын
what do you mean?
@EmptySkySora
@EmptySkySora 3 жыл бұрын
@@endcraftable the system used in the video is obsolete. Google unitywebrequest for the new scripting method.
@natnaelghirma2617
@natnaelghirma2617 3 жыл бұрын
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?
@herbou
@herbou 3 жыл бұрын
it's possible but i don't know how 😊
@natnaelghirma2617
@natnaelghirma2617 3 жыл бұрын
@@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.
@herbou
@herbou 3 жыл бұрын
i'm sure there is an answer somwhere 😊
@smitsheth8275
@smitsheth8275 3 жыл бұрын
I am getting error 404, so where do i have to store the php files ??
@herbou
@herbou 3 жыл бұрын
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
@smitsheth8275
@smitsheth8275 3 жыл бұрын
@@herbou I did the same, but now inspite of entering the correct username and password, it keeps displaying "Invalid username or password"
@shahad2331
@shahad2331 3 жыл бұрын
Is this way work when i want to do an android app and save users info?
@herbou
@herbou 3 жыл бұрын
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
@niranjanraje7160
@niranjanraje7160 3 жыл бұрын
We can do the same using nodejs as well right instead of php...?
@herbou
@herbou 3 жыл бұрын
yes
@emanuelcordovamontiel1017
@emanuelcordovamontiel1017 3 жыл бұрын
How to save the user's session? Because when an user come back to the application it will enter its credentials again.
@herbou
@herbou 3 жыл бұрын
PlayerPrefs.SetInt("isLoggedIn",1); and in the start : if (PlayerPrefs.GetInt("isLoggedIn",0)==0) Login(); else //skip login (already logged in)
@amanirahman4825
@amanirahman4825 2 жыл бұрын
@@herbou may i know where to put this code?
@fukukyun78
@fukukyun78 2 жыл бұрын
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
@CREATIVNICK
@CREATIVNICK 2 жыл бұрын
Great tuto!but i cant connect to the server! show 404 not found error
@jesper99
@jesper99 3 жыл бұрын
if i click the login button, it goes to the next screen. Even if i enter the wrong info.
@herbou
@herbou 3 жыл бұрын
that's impossible
@ahmedelgendy3616
@ahmedelgendy3616 3 жыл бұрын
This is awesome 👌👏 What about Android phones ?
@rihabbelhiba5851
@rihabbelhiba5851 4 жыл бұрын
hello thanks for the video but what if i want to make it work on wifi (remote) what do i need ??
@herbou
@herbou 4 жыл бұрын
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
@rihabbelhiba5851
@rihabbelhiba5851 4 жыл бұрын
@@herbou after i finish the build of my app on my phone and i want to run it using my server (localhost) how?
@herbou
@herbou 4 жыл бұрын
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
@herbou
@herbou 4 жыл бұрын
stackoverflow.com/questions/4779963/how-can-i-access-my-localhost-from-my-android-device
@chaiseven1562
@chaiseven1562 3 жыл бұрын
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!
@herbou
@herbou 3 жыл бұрын
if you're using a localhost it won't work in your mobile.
@pranavmohite8581
@pranavmohite8581 2 жыл бұрын
Which IDE are u using for php
@herbou
@herbou 2 жыл бұрын
sublime text
@cotafei
@cotafei 2 жыл бұрын
will there be a continuation with registration?
@herbou
@herbou 2 жыл бұрын
I'm afraid not. because it's the same logic, you just need the SQL code to add users to the database
@monchiquediscovery
@monchiquediscovery 3 жыл бұрын
Hi Tank You For The Great Tutorial , i have a question wish encriptation you use in the password?
@herbou
@herbou 3 жыл бұрын
sha1
@revotiva
@revotiva 4 жыл бұрын
can i use this for mobile?
@herbou
@herbou 4 жыл бұрын
Yes of course
@SKJagan-dh2ft
@SKJagan-dh2ft 3 жыл бұрын
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!
@herbou
@herbou 3 жыл бұрын
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-dh2ft
@SKJagan-dh2ft 3 жыл бұрын
@@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.
@herbou
@herbou 3 жыл бұрын
I didn't use firebase before but maybe in a future video , sorry 🙏
@SKJagan-dh2ft
@SKJagan-dh2ft 3 жыл бұрын
@@herbou even I'm not bound to it, can you suggest any other platform than firebase!
@tineswaranchandran8992
@tineswaranchandran8992 4 жыл бұрын
if you enter username and password, it came out 'invalid username or password!'. Try remove sha1 that used for password encryption
@herbou
@herbou 4 жыл бұрын
I used Sha1 encryption in the Database .that's why it works for me.
@herbou
@herbou 4 жыл бұрын
github.com/herbou/Tuto_Unity_SendDataToServer/blob/master/___ServerFolder_www/unity/api/__database__.sql
@LazyCliqueOFC
@LazyCliqueOFC 3 жыл бұрын
Same, always fgetting invalid password
@herbou
@herbou 3 жыл бұрын
can you show me the users passwords in the database??
@kevincranfield2471
@kevincranfield2471 3 жыл бұрын
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(); }
@saifgames2468
@saifgames2468 4 жыл бұрын
Amazing tutorial, i'm using binary saving data in my game how can i send it to a server ?
@herbou
@herbou 4 жыл бұрын
simple text data?
@saifgames2468
@saifgames2468 4 жыл бұрын
@@herbou binary data
@herbou
@herbou 4 жыл бұрын
But they are simple text data during the game?
@herbou
@herbou 4 жыл бұрын
If true the simply send to server before saving in files as binary
@saifgames2468
@saifgames2468 4 жыл бұрын
@@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
@sergiocamoleze1156
@sergiocamoleze1156 2 жыл бұрын
The password needs to be encrypted in unity3d to not be transported over the internet unencrypted
@Benzitczo
@Benzitczo Жыл бұрын
missing need REGISTER
@danielspriggan2987
@danielspriggan2987 3 жыл бұрын
and...registry?
@herbou
@herbou 3 жыл бұрын
same steps, you need just some change in the server side (php)
@brittanymiller8590
@brittanymiller8590 2 жыл бұрын
It don't work(
Unity load data from server in JSON format ,load images
6:09
Hamza Herbou
Рет қаралды 25 М.
【Unity Easy Backend】User Login - Sending data to our server
14:24
Fire Brain Games (Creagines)
Рет қаралды 45 М.
Дарю Самокат Скейтеру !
00:42
Vlad Samokatchik
Рет қаралды 8 МЛН
Каха и суп
00:39
К-Media
Рет қаралды 6 МЛН
Unity & MySQL Databases, Part 1: Setting Up
17:19
Board To Bits Games
Рет қаралды 153 М.
Where Did Arch Linux Come From?
16:21
Action Retro
Рет қаралды 9 М.
Unity User Login System Tutorial - Firebase Authentication
14:07
xzippyzachx
Рет қаралды 111 М.
【Unity Easy Backend】Login UI - Interface Scripting
14:38
Fire Brain Games (Creagines)
Рет қаралды 33 М.
SETTINGS MENU in Unity
17:22
Brackeys
Рет қаралды 933 М.
Unity User Data & Scoreboard Tutorial - Firebase Realtime Database
25:11
Easy Smooth and Dynamic Coin Collecting with DoTween in Unity
13:49