Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity <-> php + mySQL

Discussion in 'Getting Started' started by eljuko, Sep 30, 2016.

  1. eljuko

    eljuko

    Joined:
    Sep 30, 2016
    Posts:
    4
    Hey everyone!

    Started to learn Unity yesterday and long story short; i'm failing to get mySQL query right with email(works with password only?!), maybe i'm missing something.

    Php code:

    Code (CSharp):
    1. <?php
    2.     require_once('mysqlcon.php');
    3.  
    4.     $email = $_POST['eMail'];
    5.     $pw = md5($_POST['password']);
    6.  
    7.     $result = mysql_query("SELECT * FROM Users WHERE eMail='$email' AND pw='$pw'", $db);
    8.     $row = mysql_fetch_assoc($result);
    9.  
    10.     echo $row['un'];
    11. ?>
    javascript goes like this
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var email : String;
    4. var password : String;
    5.  
    6. var emailField : UnityEngine.UI.InputField;
    7. var passwordField : UnityEngine.UI.InputField;
    8.  
    9.  
    10. function checkInputs(){
    11.  
    12.  
    13.     email = emailField.text;
    14.     password = passwordField.text;
    15.  
    16.     var url = "http://myUrl.forSecurity";
    17.     var form = new WWWForm();
    18.     form.AddField( "eMail", email );
    19.     form.AddField( "password", password);
    20.     var download = new WWW( url, form.data);
    21.     while(!download.isDone){
    22.  
    23.     }
    24.     emailField.text = download.data;
    25. }
    I'v checked the MySQL database if the names / types are right and they should be. Anyone who can help me out? :)

    EDIT: code is confirmed to be working from webpage.
     
    Last edited: Sep 30, 2016
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,903
    Are you calling the checkInputs() function somewhere?
     
  3. eljuko

    eljuko

    Joined:
    Sep 30, 2016
    Posts:
    4
    Yeah. checkInputs calls from "login" -button.
     
  4. eljuko

    eljuko

    Joined:
    Sep 30, 2016
    Posts:
    4
    no one? i suppose i need to completely rework that snippet.