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
0
Question by Kiran Viraktamath · Apr 30, 2011 at 10:24 AM · networkwwwlogin

sending values to server script

Hi all, I am new to this unity world and to PHP, the following question may seems repeated but I am stuck in this - I am trying to send values from Unity content to server script, I followed this link to initiate 1. But I am not getting any values in server(configured in the same system) side. I am running my PHP using "EasyPHP" tool. When I run my program in Unity editor it is showing as data sent , and when i run my PHP ,it is showing as

Notice: Undefined index: username in C:\Program Files\EasyPHP-5.3.6.0\www\LoginTest.php on line 2

Notice: Undefined index: passwordscore in C:\Program Files\EasyPHP-5.3.6.0\www\LoginTest.php on line 3

Following are my code snippets , please help me in where am i going wrong- PHP file at server side -

Login.php

    <?php echo $_POST['username']; ?>
 <?php echo $_POST['passwordscore']; ?> 

Javascript File in Unity-

Login.js

// start var userNameToEdit : String = "Your ID";

var passwordToEdit : String ;

var form:WWWForm;

var LoginTestURL = "http://127.0.0.1:8888/Login.php";

function Start() { // Create a form object for sending high score data to the server form = new WWWForm(); }

function OnGUI () { // Make a text field that modifies stringToEdit. userNameToEdit = GUI.TextField (Rect (110, 10, 200, 20), userNameToEdit, 10);

 // Make a password field that modifies passwordToEdit.
 passwordToEdit = GUI.PasswordField (Rect (110, 40, 200, 20), passwordToEdit, "*"[0], 10);

 if (GUI.Button(Rect(110,70,60,25),"Login"))
 {
     print("Clicked the button with text");
     print(userNameToEdit);
     print(passwordToEdit);  

     sendLoginData();  


 }

}

function sendLoginData() { form.AddField( "username", userNameToEdit );

     form.AddField( "password", passwordToEdit);


     var w = new WWW(LoginTestURL, form);

     yield w;
     if (w.error != null)
         print(w.error);
     else
         print("Finished Uploading LoginData"); 

} function Update () {

}

Login.js end

I have one more problem that it is started showing "Finished Uploading LoginData" even i give wrong URL. Please suggest something on the above problem.

Thanking All in advance-

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 DaveA · Apr 30, 2011 at 05:22 PM

What do you mean by 'run PHP'?

What I usually do is make a stand-alone HTML page (for POST forms), or use GET and just hit the URL, to test the PHP by itself and make sure it's working.

In your script, add Debug.Log("Got back:"+w.text); to see what comes back

Comment
Add comment · Show 3 · 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 Kiran Viraktamath · May 03, 2011 at 01:39 PM 0
Share

Hey thanks for the reply.. I tested my PHP with two defferent files to pass values between them and they r working fine on web. And when come to javascript, i added Debug.Log statement , I got an error which says Object not found. And it sorted out by creating new project and code i inserted the same thing and guess what it worked and printed back my Username and Password on webplayer.

avatar image DaveA · May 03, 2011 at 05:41 PM 0
Share

The object not found must have been the w for some reason. Has it helped at all?

avatar image Kiran Viraktamath · May 04, 2011 at 09:51 AM 0
Share

Yes. It helped me. Thanks.

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

No one has followed this question yet.

Related Questions

Getting info using WWW & PHP 3 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

www class works fine in android but doesn't work in ios... 0 Answers

modernized master server script? 1 Answer

Is it possible to have a server deliver complete levels to an otherwise empty client? 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