Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by dillfunk · May 24, 2018 at 02:21 AM · loginmysqlphpauthentication

Login authentication on Unity 5 with php using xampp, and mysqli

i am trying to figure out what the best way is to handle login authentication security wise. in my php code, it handles when a username exists in the database, and if the password is correct, it will display message "Login successful", but there isn't any sort of validation whether the user is successfully logged in, it just displays the message. here's my php code

//connection to db $conn = new mysqli($server_hostname, $server_username, $server_password, $db_name);

 //check sqli connection
 if (mysqli_connect_errno()){
     echo "Failed to connect to DB: ".mysqli_connect_error();
 }
 
 //login post variables
 $user_username = mysqli_real_escape_string($conn, $_POST["usernamePost"]);
 $user_password = mysqli_real_escape_string($conn, $_POST["passwordPost"]);

 //check is password is correct
 $check_password = "SELECT password FROM users WHERE username = '$user_username'";
 $result = mysqli_query($conn, $check_password);

 //check empty field
 if (empty($user_username) || empty($user_password)){
     echo "This field is required";
 }

 //only one unique username should be found
 else if (mysqli_num_rows($result) == 1){
     while ($row = mysqli_fetch_assoc($result)){
         if($row['password'] == md5($user_password)){
             echo "Login successful";
         }
         else{
             echo "Incorrect password";
         }
     }
 }
 else{
     echo "Username is not found";
 }

inside unity, when login button is pressed, if the user enters wrong password or username, it just displays the message saying that there is an error without any sort of security mechanism. same as when a user is successfully logged in, it just echo "Login successful". what i want to do is when a user is successfully logged in, it will validate that the user is logged in, and bring up the database for that user only. i'm just not sure what the best way to handle this security wise. sorry for bad english.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Lost_Syndicate · May 24, 2018 at 02:29 AM 0
Share

$$anonymous$$y question is: Why use SQL xamp and php in unity lmao why cant you use c#

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

84 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity PHP login always returning true 3 Answers

Mysql PDO Register user insert not inserting, no error feedback 0 Answers

How Do i check for Duplicate username in database 4 Answers

security with mysql 1 Answer

Unity Null Reference Error 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges