title: How can I access a PHP file on a server via Unity for MySQL- database manipulation?
body: <p>I'm currently developing a login system for an online Unity game. My goal is to have a database on my server and to check if the user is registered. 
  I followed this <a href="https://appnimiacademy.com/email-authentication-in-unity-with-php-and-mysql-as-backend/" rel="nofollow noreferrer">tutorial</a>, if you need more background information than provided.</p>
  
  <p>I have a PHP script on my server and a database. The PHP script is under the default folder of my web server (purplepandagames.com/httpdocs/auth.php). </p>
  
  <pre><code>$hostname = "&lt;localhost:3306&gt;";
  $username = "&lt;username&gt;";
  $dbname = "&lt;dbName&gt;";
  $password = "&lt;password&gt;";
  
  mysql_connect($hostname, $username, $password) OR DIE ("Unable to connect to database! Please try again later.");
  mysql_select_db($dbname);
  
  </code></pre>
  
  <p>To connect to the server I use these values in my PHP script. Is localhost correct? Or is the hostname purplepandagames.com? The database is attached to purplepandagams.com.</p>
  
  <p>In Unity, I have a script called AuthManager, which handles the connection. Here are some parts of the C# script that might be wrong: </p>
  
  <pre><code>string authphpurl = "https://purplepandagames.com/auth.php";    //enter the complete URL for auth.php
  
      IEnumerator PostDataForLogin()
      {     
          WWWForm form = new WWWForm();
          form.AddField("email", emailText.text);
          form.AddField("pwd", passwordText.text);
  
          var url = authphpurl + "?action=login";
  
          UnityWebRequest www = UnityWebRequest.Post(url, form);
  
          yield return www.SendWebRequest();
  
          Debug.Log("Response:" + www.downloadHandler.text);
  
          if (www.isNetworkError || www.isHttpError)
          {
              Debug.Log(www.error);
              responseText.text = www.error;
          }
          else
          {
  
              Debug.Log("Form upload complete!");
  
              JSONNode jsonNode = SimpleJSON.JSON.Parse(www.downloadHandler.text);
              Debug.Log("success : " + jsonNode["success"]);
              Debug.Log("message : " + jsonNode["msg"]);
  
  
              responseText.text = jsonNode["msg"];
          }
       }
  </code></pre>
  
  <p>For simpleJSON I'm using <a href="http://wiki.unity3d.com/index.php/SimpleJSON" rel="nofollow noreferrer">this</a>.</p>
  
  <p>If I run the code like this, the error message <code>HTTP/1.1 500 Internal Server Error</code> appears. If I change the authphpurl to only <a href="https://purplepandagames.com" rel="nofollow noreferrer">https://purplepandagames.com</a>, there is no feedback and the         <code>Debug.Log("Response:" + www.downloadHandler.text);</code> statement just outputs the index.html file.</p>
  
  <p>The website has an SSL certification, this could be a problem.</p>
  
  <p>And in general, is it even a good idea to solve this problem like this? I would encrypt the passwords before uploading to the database. But at the moment I do not understand what prevents other people of being able to manipulate this database as well.</p>