This PHP script is meant to post a users name into a database but it doesnt seem to work properly. The project in unity wont post it correctly and going straight to IP
ADDRESS/addUser.php?NAME=Ryan
also doesnt work. It auto increments the ID as it should but the name field is always blank.
<?php
//Connect
$sql_connect = mysql_connect("IP", "USER", "PASS") or die ("no DB Connection");
//Select Database
mysql_select_db("practiceCrim") or die ("DB not found");
//Post Info To Var
$name = $_POST['NAME'];
//Query
$query = "INSERT INTO Users (Name)
VALUES ('$name')";
//Run The Query, Get Result
$result = mysql_query( $query, $sql_connect );
//Not Really Needed For You
if(!$result)
{
die('Error: ' . mysql_error());
}
//Close The Connection
mysql_close($sql_connect);
?>
It look like you're getting the name field from the PHP $_POST variable. But your example passes the name field as a GET parameter.
To fix this, you have two options. If you only want to allow name to be passed as a GET parameter, then you need to do this:
$name = $_GET["NAME"];
If you want to allow name to be passed as either a GET or a POST parameter, you can do this:
$name = $_REQUEST["NAME"];
you should replace $name = $_POST['NAME'] with $name = $_GET['NAME'] or $name = $_REQUEST['NAME'] where $_REQUEST is default but don't use $_REQUEST