This is the html code This is a snap of the code, I could not paste it as it will take me time to format it properly
答案 0 :(得分:0)
确保在html中有一个输入名称"名称"在html。
如果它不发布$_POST['Name']
- 它将不会进入条件,因此将抛出错误,因为$Name
将不会被初始化 - 将$Name
定义为null代码:
<?php include('connect.php'); ?>
<?php
$Name = ""; // define $Name as null first
if (isset($_POST['Name'])) {
$Name = $_POST['Name'];
}
$query = "INSERT INTO expense (Name, Amount, Comment,UserId) " . "VALUES '$Name','$_POST[Amount]','$_POST[Comment]','$_POST[UserId]')"; $result = mysqli_query($dbc, $query);
if ($result) { echo 'SUCCESSS:'; } else {
echo 'NOPE:'; mysqli_error($dbc); echo $query;
}
?>