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 caesarpena · Oct 13, 2016 at 09:09 PM · phprequest

Send Data From C# to PHP Server

Any one has an idea why this is not working?

C# code in unity

     WWWForm form = new WWWForm();

     form.AddField("tablenamepost", "furniture");

     WWW www = new WWW(url, form);


PHP code server

      if(isset($_POST["tablenamepost"])) {

     echo $POST["tablenamepost"];
     
     }
     
     else echo "error";


i always get "eror" when refreshing the url since nothing its coming from unity....the url its fine.

Comment
Add comment · Show 4
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 Bunny83 · Oct 14, 2016 at 12:05 PM 0
Share

Do you actually read the return value inside Unity? Do you do your WWW call in a coroutine?

Also note that you check if "$_POST...." is set but then you use "$POST....". $$anonymous$$aybe you setup your server wrong so it might not create certain globals depending on the PHP config.

You haven't provided enough information so we can't give you an exact answer. There are by far too many "unknown variables" here.

ps: If you want to improve your question, feel free to edit it by pressing the little "cogwheel" at the top right of your question and select "edit".

avatar image caesarpena Bunny83 · Oct 14, 2016 at 01:34 PM 0
Share

Thank you for your response, i fixed the "$POST" issue in the php file

"$$anonymous$$aybe you setup your server wrong so it might not create certain globals depending on the PHP config" - i dont think so because im able to get data from the server.

Now i added a corroutine and i have something like this but stills not working :(

 void Start () {



     WWWForm form = new WWWForm();
     form.AddField("tablenamepost", "furniture");
     WWW www = new WWW(url, form);

     StartCoroutine(WaitForRequest(www));

 }




 IEnumerator WaitForRequest(WWW www)
 {
     yield return www;

      // check for errors
     if (www.error == null)
     {
         Debug.Log("WWW Ok!: " + www.data);
     }
     else
     {
         Debug.Log("WWW Error: " + www.error);
     }
 }
avatar image Zodiarc caesarpena · Oct 14, 2016 at 01:40 PM 0
Share

Did you make a var_dump of $_POST (or if it's too big a print_r) and see what $_POST actually contains? I don't have experience with the unit WWWForm class, but how do you know the value isn't set as a GET-parameter? Did you look in $_GET if it exists there? Is the php script actually printing anything? And is the webserver the script is running on configured correctly?

avatar image Zodiarc · Oct 14, 2016 at 01:29 PM 0
Share

I would recommend you to create a soap or rest service for those tasks.

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

58 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

Related Questions

UnityWebRequest Post Not Returning Anything 1 Answer

Best online servers for Web Browser Multiplayer? 2 Answers

Read second Line of WWWForm.data 1 Answer

Retrieve a value from a PHP file and print it on the Unity3D console. 1 Answer

unity + php get Authentication 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