Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by kmccmk9 · Jul 10, 2012 at 05:42 AM · wwwfunctionmysqlphp

Unity php functions

Hello, I have a php check login function on my webserver that returns either true or false via a checklogin function. How do I go about calling the php function from within unity? Assuming I already have the two strings for username and password. Thanks.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by flamy · Jul 10, 2012 at 06:14 AM

you have to use either WWW class or WWWForm Class for this.

 private  IEnumerator authorize()
     {
  
 
         // replace php path  with  the address to the php file
         string post_url =phpPath+ "?username=" + WWW.EscapeURL(profileName) + "&password=" + WWW.EscapeURL(password);
 
         // Post the URL to the site and create a download object to get the result.
         WWW hs_post = new WWW(post_url);
         yield return hs_post; // Wait until the download is done
  
         if (hs_post.error != null)
         {
             Debug.Log("error"+);
         }
      else
      {
              if(hs_post.text=="true")
              {
                  //logged in..
              }
              else
              {
                  //not logged in
              }
         }
 }
 // and somewhere in the code call  
 StartCoroutine(authorize());

check this link , this will explain you in a much better way.

Comment
Add comment · Show 5 · Share
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 kmccmk9 · Jul 10, 2012 at 06:21 AM 0
Share

Hi thanks for the response. $$anonymous$$y question should be restated as, if I have a checklogin function in my php file, how do I access it from unity code?

avatar image flamy · Jul 10, 2012 at 06:28 AM 0
Share

that should be simple.... if the php file has a lot of functions, you can pass another argument like username or password for which function to be called...

and in the php file check if the argument is equal to login and call the respective function. there aint a direct way to call the function you need.

ref: http://stackoverflow.com/questions/4360182/call-php-function-from-url

avatar image hirenkacha · Jun 27, 2013 at 11:08 AM 2
Share

@flamy : Thats great.. Thanx.. Helped me too.. +1 upvote.. @kmccmk9 : Accept the answer if its right.

avatar image Bunny83 · Jun 27, 2013 at 11:41 AM 1
Share

Since this is an old question, the OP was last seen several weeks ago and he only accepted 1 of his 30 questions, I accepted this answer.

avatar image kmccmk9 · Jun 27, 2013 at 03:46 PM 0
Share

Sorry, I have been gone for a long time with school. I am back now and to be honest when I first started using this site I was using it more like a forum and didn't understand how everything worked. Although now, a year later and a lot more experience using similar sites like StackOverflow, I know how important it is to accept answers. I'm already going through all my old questions. Sorry again.

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

8 People are following this question.

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

Related Questions

Retrieving data from a WWW php call? 1 Answer

Multistage Delete with WWW 1 Answer

Unity CrossDomain.xml Still Required? What is wrong? 0 Answers

How do I properly send binary data (byte[]) to a MySQL database? 4 Answers

Unity - MySQL data loss 0 Answers


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