我正在尝试在我的数据库表中发布我在000webhost phpmyadmin服务器中创建的值。要发布/检查我正在使用邮递员软件。 在postman软件中,我传递了键值对(在表单数据选择中,也尝试传递x-www-form-urlencoded)。但是添加的值是null。并不是说我传递了键值对。
当我在没有任何键值对的情况下传递时,它仍会在我的表中添加空值的行。 请帮忙解决.. 我让这个api在我的android应用程序中使用它。
这是我的PHP代码:
confi.php:
<?php
error_reporting(1);
$conn = mysqli_connect("localhost", "********", "******","id1536885_mydb");
?>
individualuser_details.php:
<?php
// Include confi.php
include_once('confi.php');
if($_SERVER['REQUEST_METHOD'] == "POST"){
// Get data
$name = isset($_POST['name']) ? mysqli_real_escape_string($_POST['name']) : "";
$adhar = isset($_POST['adhar']) ? mysqli_real_escape_string($_POST['adhar']) : "";
$email = isset($_POST['email']) ? mysqli_real_escape_string($_POST['email']) : "";
$password = isset($_POST['password']) ? mysqli_real_escape_string($_POST['password']) : "";
$contact = isset($_POST['contact']) ? mysqli_real_escape_string($_POST['contact']) : "";
$status = isset($_POST['status']) ? mysqli_real_escape_string($_POST['status']) : "";
//echo $name.' no';
// Insert data into data base
$sql ="INSERT INTO id1536885_mydb.`individualuser_details` (`ID`, `name`, `adhar`, `email`, `password`, `contact`, `status`) VALUES (NULL, '$name', '$adhar', '$email', '$password', '$contact', '$status');";
// echo $sql;
$qur = mysqli_query($conn,$sql);
if($qur){
$json = array("status" => 1, "msg" => "Done User added!");
}else{
$json = array("status" => 0, "msg" => "Error adding user!");
}
}else{
$json = array("status" => 0, "msg" => "Request method not accepted");
}
@mysqli_close($conn);
/* Output header */
header('Content-type: application/json');
echo json_encode($json);
?>