• 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 Manveru · May 11, 2015 at 12:24 PM · c#wwwphpwwwformpost

PHP POST through $_REQUEST with WEBBUILD

Hi, i have app, that using php to store and use data from MySQL. All working fine in PC build and in editor play mode. But when i'm using Webbuild - application give nosing to PHP script. That is seem like webbuild can't give POST data, or i do something wrong. Anyway, there's C#:

  public IEnumerator SendDataToWeb(string answer, string id){
               if (coroutineInProcess == false){
                  coroutineInProcess = true;
                  WWWForm form = new WWWForm();
                  form.AddField( "UserID", id);
                  form.AddField( "Answer", answer );
          
          //wwwSendData get his value in diferent part of code
                  WWW download = new WWW( wwwSendData, form );
                  yield return download;        
                  if(!string.IsNullOrEmpty(download.error))
  {
                      Debug.Log ( "Error downloading: " + download.error );
                  } else {
                      Debug.Log ( download.text );
                  }
                  coroutineInProcess = false;
               }
              }

And there's php:

 <?php
 $userID = $_REQUEST['UserID'];
 $answer = $_REQUEST['Answer'];
 
 
 $host = 'localhost'; 
 $user = 'testUser'; 
 $password = '123qweasd'; 
 $db = 'testdb'; 
 $table = 'highscores'; 
 
 mysql_connect($host, $user, $password) or die(mysql_error()); 
 mysql_select_db($db); 
 
 $password = md5($password); 
 
 
 mysql_query("DELETE FROM `answers` WHERE  TO_DAYS(NOW())- TO_DAYS(dateValue) = 0 AND ID = '{$userID}' ") or die (mysql_error());
 
 
 mysql_query("INSERT INTO `answers` (ID, answer) VALUES ('{$userID}', '{$answer}')") or die (mysql_error());
 
 echo "Done";
 
 ?>

 

I adeed crossdomain.xml in root of my site. I Test all this stuff on denwer. Repeat: all working, exept post data from web build. In PC build and editor play mode all work without problems.

Sorry for bad knowlege of English.

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
0

Answer by Manveru · May 13, 2015 at 09:25 AM

For now, im using handmaded strings. I add strings to URL like this:

 public IEnumerator SendDataToWeb(string answer, string id){
          if (coroutineInProcess == false){
             coroutineInProcess = true;
             Debug.Log (answer);
             string getRequest1 = "UserID="+id; 
             string getRequest2 = "&Answer="+answer;     
             WWW download = new WWW( wwwSendData+"?"+getRequest1+getRequest2);
             yield return download;
             
             
             if(!string.IsNullOrEmpty(download.error)) {
                 Debug.Log ( "Error downloading: " + download.error );
             } else {
                 Debug.Log ( download.text );
             }
             coroutineInProcess = false;
          }
         }
 




I's working, but I'm not shure that this is safe and right...

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

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Sending variables to HTML 1 Answer

WWWForm always returning Internal Server Error 1 Answer

POST a form over HTTPS with unvalidated SSL Certificate 2 Answers

WWW form isn't working in Build 1 Answer

How do I send data over the internet? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges