php - 未定义变量:C:\xampp\htdocs\redo\consultation.php 中第 21 行 PHP 中的详细信息
问题描述
<?php include 'connection.php'; ?>
<?php
if (isset($_GET['consultation']))
{
echo "Consultation Details";
$no=$_GET['consultation'];
?>
<form class="" method="get">
<textarea name="details" rows="8" cols="80" placeholder="enter consultation details"></textarea><br>
<button type="submit" name="c">submit</button>
</form>
<?php
if (isset($_GET['details'])) {
$details=$_GET['details'];
}
//$details= $_GET['details'];
$insertQuery="INSERT INTO redo (consultation) VALUES ($details) WHERE no=$no;";
$insert = mysqli_query($conn,$insertQuery);
if ($insert) {
echo "recorded";
?>
<a href="display.php">Back to Total Patients</a>
<a href="index.php">Back to Registration</a>
<?php
}
else {
echo "record couldnt be inserted";
}
}
?>
解决方案
不$_GET['details']
,您确定您使用的GET
是表单中的方法吗?更改$_GET['details']
为$_REQUEST['details']
。
确切地说,这个失败了:
if (isset($_GET['details'])) {
$details=$_GET['details'];
}
我的意思是,if
条件不满足,所以$details
没有定义,因为你没有在if
.
其他解决方案是添加:
$details = '';
在那之前if
。
推荐阅读
- python - 熊猫左合并是否保留左df中的行顺序
- python - Python:尝试通过 OpenCV 连接到 RTSP 相机时,有没有办法设置超时/异常?
- javascript - 如何在组合 API 中发出值
- python - 如何用python删除文件夹?
- reactjs - 如何解决 React 环境文件中的 API 密钥 401 错误?
- python - 如何避免每个命令的ifs?
- python - 如何在硒中切换窗口并保持窗口最小化?
- javascript - 如何使用 Ionic Capacitor 启用捏缩放?
- python - 如何使用生成器训练 XGBoost?
- powerbi - 根据在 Power BI 中搜索单独字段查找周围的索引记录