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 akrala · Jan 12, 2015 at 10:16 PM · c#loginphpwwwformuser

How to use php login Form [POST] with c#

Hello, so i want o make user loins in unity. I saw a tutorial on this, and they used WWW, but however the php script used method 'GET' instead of mehtod 'POST'. For all the programmers out there you know why this is bad. How do i have a c# scirpt that uses a php code with Post method instead of a get method? LINKS to tutorials, or an example code would be most helpful, thanks

PHP login script

 <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
 <tr>
 <form name="form1" method="post" action="check_login.php">
 <td>
 <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
 <tr>
 <td colspan="3"><strong>Member Login </strong></td>
 </tr>
 <tr>
 <td width="78">Username</td>
 <td width="6">:</td>
 <td width="294"><input name="myusername" type="text" id="myusername"></td>
 </tr>
 <tr>
 <td>Password</td>
 <td>:</td>
 <td><input name="mypassword" type="password" id="mypassword"></td>
 </tr>
 <tr>
 <td> </td>
 <td> </td>
 <td><input type="submit" name="Submit" value="Login"></td>
 </tr>
 </table>
 </td>
 </form>
 </tr>
 </table>

Current c# code using UnityEngine; using System.Collections;

 public class LoginMenu : MonoBehaviour {
     string loginUrl = "";
     string username =""; 
     string password =""; 
     string label =""; 
 
 
     void OnGUI(){
         GUI.Window(0,new Rect(Screen.width / 4, Screen.height / 4, Screen.width / 2, Screen.height /2 - 70), LoginWindow,"Login");
     }
     void LoginWindow(int windowID){
     GUI.Label (new Rect (140,40,130,100), "____________username____________");
     username = GUI.TextField(new Rect(25,60,375,30),username); 
     GUI.Label (new Rect (140,92,130,100), "____________password____________");
     password = GUI.PasswordField (new Rect (25,115, 375, 30),password, "");
     
     GUI.Button ( new Rect (25,160,375,50), "Login"); //turn to button with if statment 
     }
     
     IEnumerable HnaldeLogin(string username, string password){
     label = "Checking username and password..."; 
     string loginUrl = this.loginUrl+"?username="+username+"&password="+password ;
     WWW loginReader = new WWW(loinUrl);
     yield return loginReader;
         if(loginReader.error != null){
         label="Error connecting to database server";
         } else {
             if(loginReader.text =="success"){
             label = "Successfully logged in";
             } else{
             label = "invalid Username or password ";
             }
             
         }
         }
     
 }
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
2

Answer by Graham-Dunnett · Jan 12, 2015 at 10:18 PM

Reading docs is good:

http://docs.unity3d.com/ScriptReference/WWWForm.html

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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Send an integer array through WWWForm 1 Answer

WWWForm always returning Internal Server Error 1 Answer

WWW form isn't working in Build 1 Answer

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 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