Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Registr : MonoBehaviour
- {
- public InputField groupfield;
- public InputField namefield;
- public InputField surnamefield;
- public Button submitButton;
- public void CallRegister()
- {
- StartCoroutine(Register());
- }
- IEnumerator Register()
- {
- WWWForm form = new WWWForm();
- form.AddField("name", namefield.text);
- form.AddField("surname", surnamefield.text);
- form.AddField("group", groupfield.text);
- WWW www = new WWW("http://localhost/sqlconnect/register.php", form);
- yield return www;
- if (www.text == "0"){
- Debug.Log("User created ");
- }
- else
- {
- Debug.Log("User creation failed:" + www.text);
- }
- }
- public void VerifyInputs()
- {
- submitButton.interactable = (namefield.text.Length >= 2 && surnamefield.text.Length >= 4);
- }
- }
- ----------------------------------------------------
- php:
- <?php
- $con = mysqli_connect('localhost','root','root','unityaccess');
- if (mysqli_connect_errno())
- {
- echo "1";
- exit();
- }
- $username = $_POST["name"];
- $usersurname = $_POST["surname"];
- $usergroup = $_POST["group"];
- $insertuserquery = "INSERT INTO students (username,usersurname,usergroup) VALUES ('" . $username . "', '" . $usersurname ."', '" .$usergroup ."');";
- mysqli_query($con, $insertuserquery) or die ("4: insert failed");
- echo("0");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement