i have a problem with my php registration's script. This is my code:
<?php
//response è un array
$response = array();
//response con chiave success, ha valore -1
$response["success"] = -1;
/*ci colleghiamo al database(attenti perchè se lavorate in locale
l'host è 10.0.2.2 e non 127.0.0.1)*/
mysql_connect("localhost","fbaprova","")
or die("Impossibile connettersi al server MySQL.
");
//selezioniamo il db a cui ci vogliamo connettere
mysql_select_db("my_fbaprova")
or die("Impossibile aprire il database.
");
//creo la tabella nel database
mysql_query("CREATE TABLE IF NOT EXISTS `my_fbaprova`.`Utente` (
`Ut_Id` INT NOT NULL AUTO_INCREMENT,
`Ut_Username` VARCHAR(45) NOT NULL,
`Ut_Email` VARCHAR(45) NOT NULL,
`Ut_Password` VARCHAR(45) NOT NULL,
`Ut_PartiteVinte` INT NOT NULL,
`Ut_PartitePerse` INT NOT NULL,
PRIMARY KEY (`Ut_Id`))
ENGINE = InnoDB;");
//inserisco i dati nell'array post
$Ut_Username = $_POST['Ut_Username'];
$Ut_Email = $_POST['Ut_Email'];
$Ut_Password = $_POST['Ut_Password'];
$Ut_PartiteVinte = $_POST['Ut_PartiteVinte'];
$Ut_PartitePerse = $_POST['Ut_PartitePerse'];
//usarlo per la registrazione
$result = mysql_query("INSERT INTO `my_fbaprova`.`Utente`
( `Ut_Username`, `Ut_Email`,`Ut_Password` , `Ut_PartiteVinte`, `Ut_PartitePerse`)
VALUES ($Ut_Username, $Ut_Email, $Ut_Password, $Ut_PartiteVinte, $Ut_PartitePerse;");
if($result){
// success
$response["success"]= 1;
}else{
//insuccess
$response["success"] = -1;
}
// il response sarà = 1 se i dati sono stati inseriti, altrimenti sarà uguale a -1 nel caso l'username o l'email sia già presente nel db
echo json_encode($response);
mysql_close();
?>
But when i simulated A post with Postman application, from chrome store, the result is always success =-1.
as you'll see, i've not many experience with php. However, with this code, the table is created , in my db. Can someone help me?