• 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 unitytemp123 · Nov 30, 2017 at 03:07 PM · databasewwwformform

Help with unity form.Addfield

Hello you all

I'm really stuck with something i don't see why it is not working.

My goal is to send a POST variable from unity to a php file. The php file is working fine and when i submit a POST with an regular HTML form it is working. But not when i send it from unity.

Here is the code (i am using a example from unity itself)

using UnityEngine; using System.Collections; using UnityEngine.Networking;

 public class FormSender : MonoBehaviour
 {
 
 public string discipline;
 
 void Start()
 {
     StartCoroutine(Upload());
 }
 
 IEnumerator Upload()
 {
     WWWForm form = new WWWForm();
     form.AddField("Discipline", discipline);
 
     UnityWebRequest www = UnityWebRequest.Post("myworkingform.php", form);
     yield return www.SendWebRequest();
 
     if (www.isNetworkError || www.isHttpError)
     {
         Debug.Log(www.error);
     }
     else
     {
         Debug.Log("Form upload complete!");
     }
 }
 }

And in my php file i retrieve it like this: $discipline = $_POST['Discipline'];

(i don;t think it is in the php because with a regular HTML form it is working fine).

I really dont see what i am doing wrong.

Can someone help me??

Thnx

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
0

Answer by khanhabib · Dec 16, 2019 at 07:45 AM

Add url in in c# script

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

76 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

What exactly does the wwwform.addfield do exactly? 0 Answers

Problem with wwwform 3 Answers

Log in on a website and get data 0 Answers

Upload files to a remote form using C# in Unity 2 Answers

WWWForm Question 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges