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 davidflynn2 · Nov 27, 2012 at 09:02 PM · login

Login script Problem

I have found the following login scrit but for some reason no matter what you type in it lets you login.

 private var formNick = ""; //this is the field where the player will put the name to login
 private var formPassword = ""; //this is his password
 var formText = ""; //this field is where the messages sent by PHP script will be in
  
 var URL = "http://mywebsite/check_scores.php"; //change for your URL
 var hash = "yourpassword"; //change your secret code, and remember to change into the PHP file too
  
 private var textrect = Rect (10, 300, 200, 75); //just make a GUI object rectangle
 
 var username = "test";
     var userpassword="test";
 
     var areaHeight = 240;
      var areaWidth = 200;
     
     var areaHeightReg=240;
     var areaWidthReg=200;
 
 
         
     var  background: Texture2D;
     var gui : GUISkin;
  
 function OnGUI() {
 
 
     GUI.TextArea( textrect, formText );
    
 
 GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), background);
 GUI.skin = gui;
 
 
 var ScreenX = ((Screen.width / 2) - (areaWidth / 2));
        var ScreenY = ((Screen.height / 2) - (areaHeight/ 2));
        
        GUILayout.BeginArea (new Rect (ScreenX, ScreenY, areaWidth, areaHeight),"Login","Window");
        
 GUILayout.Space(15);
 
 GUILayout.Label("Username: ");
 
 
  
 GUILayout.Space(40);
  
  GUILayout.Label("Password: ");
 
  
     formNick = GUI.TextField ( Rect (38, 110, 225, 20), formNick ); //here you will insert the new value to variable formNick
     
     formPassword = GUI.PasswordField ( Rect (38, 200, 225, 20), formPassword, "*"[0] ); //same as above, but for password
     
     GUILayout.Space(4);
  
     if ( GUI.Button ( Rect (80, 235, 150, 30) , "Login" ) ){ //just a button
         Login();
     }
     
     
     GUILayout.EndArea();
     
     
     
 }
  
 function Login() {
     var form = new WWWForm(); //here you create a new form connection
     form.AddField( "myform_hash", hash ); //add your hash code to the field myform_hash, check that this variable name is the same as in PHP file
     form.AddField( "myform_nick", formNick );
     form.AddField( "myform_pass", formPassword );
     var w = WWW(URL, form); //here we create a var called 'w' and we sync with our URL and the form
     yield w; //we wait for the form to check the PHP file, so our game dont just hang
     if (w.error != null) {
         print(w.error); //if there is an error, tell us
     } else {
         print("Test ok");
         formText = w.data; //here we return the data our PHP told us
         w.Dispose(); //clear our form in game
        // Application.LoadLevel("fgdf");
     }
  
     formNick = ""; //just clean our variables
     formPassword = "";
 }
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
1
Best Answer

Answer by Collapse · Nov 28, 2012 at 12:32 AM

It is probably a mistake in your php file since you can always login and the php file in your script stops you from logging in when there is an error... (that it lets you log in means that there are no w.error's)

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

12 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

Related Questions

Multiple Cars not working 1 Answer

JS to C# Translation? 2 Answers

I have 3 Questions I Need Answering, Can You Help? 1 Answer

I made a better shader how do i fix[add _Shadow Strength]help???>Sorry that im asking for to much 1 Answer

Leave space between GUILayout.Label 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