尝试使用json插入数据。执行代码并且每个案例都会插入一个空白行,而不是将特定的给定值插入到表中..帮我纠正这个..代码如下所示。
<?php
header('Content-Type: application/json');
include('dbconnect.php');
$json = isset($_POST['submit']) ? $_POST['submit'] : "";
$new = json_decode($json, true);
$sql="INSERT INTO emp(name,address,vicechancellor)
values
('".$new['name']."','".$new['address']."','".$new['vicechancellor']."')";
$res = mysqli_query($con,$sql);
if($res)
{
echo "created ";
}
else
{
echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
?>