Problem using WWW with PHP and MYSQL

I’ve set up a MySQL database, PHP script, and a C# script to try and setup a registration service. The database seems to be working correctly. When I access my PHP script through my browser it works correctly creating a username and password in my MySQL database. When I run my C# script through unity however it does not create a username or password at all. I cannot find what the issue would be if someone could help me out id be very appreciative.

PHP code:
$servername = “localhost”;
$serverusername = “”;
$serverpassword = “”;
$serverdatabasename = “accountdb”;

	$username = $_POST["usernamePost"];
	$password = $_POST["passwordPost"];
	//Make Connection
	$connection = new mysqli($servername, $serverusername, $serverpassword, $serverdatabasename);
	//Check Connection
		die("Connection failed. ". mysqli_connect_error());
	$check = "SELECT * FROM accounts WHERE `username`='".$username."'";
	$result = mysqli_query($connection , $check);	
	$numrows = mysqli_num_rows($result);
	if ($numrows == 0)
		$pass = md5($password);
		$ins = "INSERT INTO accounts (`username` ,  `password`) VALUES ('".$username."' ,  '".$password."')";
		$result = mysqli_query($connection , $ins);	
		if ($result)
			die ("Successfully Created User!");
			die ("Error: ");
		die("User already exists!");

C# Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DataInserter : MonoBehaviour {

    public InputField inputUsername;
    public InputField inputPassword;

    string createUserURL = "http://localhost/NewUser.php";

	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown(KeyCode.Space)) Register(inputUsername.text, inputPassword.text);

    public void Register(string username, string password)
        StartCoroutine(CreateUser(username, password));

    IEnumerator CreateUser(string username, string password)
        WWWForm form = new WWWForm();
        form.AddField("usernamePost", username);
        form.AddField("passwordPost", password);

        WWW www = new WWW(createUserURL, form);
        yield return www;
        if (www.error != null)
            Debug.Log("Something went wrong");

Not sure, but the problem might be from trying to run the PHP from your local computer. Try uploading to a server and seeing.

Have you tried “”? Maybe somehow the C# script cannot resolve the name correctly.

And some general notes:

MD5 hash for a password - just don’t.
Instead of using mysqli, use PDO at the very least and use prepared statements. This way you’ll prevent SQL injection. If possible, switch to an ORM. Also don’t make scripts die if the query was successful. You can just echo the message.

Try updating your unity to the latest version, that did it for me