- Home /
I can't get the value from unity to PHP
I can't get the value from unity to PHP. It always prints "No information was collected" in unity no matter what I did. It worked perfectly when I used $sql = "INSERT INTO Acount(AcountID,Date) VALUES('$AccountID','$Date')"; in other php file. The PHP file is uploaded to a web host already. Scripts are posted in the comment.
<?php
$servername = "localhost";
$server_username ="id167852_guofengting";
$password = "1744179856";
$dbName = "id167852_gloryseeker_database";
$InputID = $_POST["AccountIDpost"];
//$$anonymous$$ake Connection
$conn = new mysqli($servername, $server_username, $password, $dbName);
if(!$conn){
die("Connection Failed. ".mysqli_connect_error());
}
else echo("");
$sql = "SELECT * FRO$$anonymous$$ Acount WHERE AcountID = '$InputID'";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result)>0){
echo "Have A Existed Account";
}else{
echo("No information was collected");
}
?>
IEnumerator CheckExistAccount(string input){
string data = "";
WWWForm form = new WWWForm ();
form.AddField ("AccountIDpost",input);
WWW www = new WWW(checkAccountURL);
yield return www;
if (www.error == null) {
if (www.isDone) {
data = www.text;
Debug.Log ("ExitsAccount:" + data);
} else {
Debug.Log ("Error!!! ");
}
} else {
Debug.Log ("Error!!! ");
}
if (data == "No information was collected") {
Debug.Log ("false ");
CreateUserProccesser ();
} else if(data =="Have A Existed Account"){
Debug.Log ("true ");
}
else if(data == "Null"){
Debug.Log ("Null ");
}
}
Answer by Bunny83 · Jul 10, 2017 at 02:20 AM
You created a WWWForm but you never used it anywhere. You have to pass it to the WWW constructor:
// [ ... ]
WWWForm form = new WWWForm ();
form.AddField ("AccountIDpost",input);
WWW www = new WWW(checkAccountURL, form);
yield return www;
// [ ... ]
string createUserURL = "https:
string checkAccountURL = "https:
I have it. The problem is the php file doesn't want to accept my input somehow
Your answer
Follow this Question
Related Questions
My code to php -> sql in PC good, in Android not work. plese fast 1 Answer
Unity PHP/SQL table creation adds strange characters to table name 2 Answers
Why is my PHP echo returning entire PHP file after WWW request? 1 Answer
Getting Specific mySql Row by searching table with a name 0 Answers
Scoreboard/Leaderboard Script for both server and client? 1 Answer