我想将fid
和io_id
值插入到名为temp_fir_accept_later
的表中,这里io_id
是一个新字段,因此可以直接将其成功成功输入到数据库表中。但是fid
的值是从另一个先前创建的名为fir
的表中获取的,因此当我提交两个值时,fid
的Error表示为:
"Notice: Undefined variable: fid in C:\wamp\www\myProjectMJb\dashboard\admin_dashboard_menus\fir_accept_later.php on line 17"
。
那么我该如何解决该问题?下面我显示了我的代码:
fir_accept.php
<?php
include("connectioni.php");
$edit_record = $_GET['edit'];
$rs=mysqli_query($con,"SELECT * FROM `fir` WHERE fid='$edit_record'");
while($row=mysqli_fetch_array($rs))
{
?>
<form action="fir_accept_later.php" method="POST">
FIR id:<br>
<input type="text" name="fid" value="<?php echo $row['fid']; ?>" disabled><br>
Assigned IO id:<br>
<input type="text" name="io_id" ><br><br>
<button type="submit" name="submit">Submit</button><br>
</form>
fir_accept_later.php
<?php
include('connectioni.php');
$dbname="crime_management";
$conn=mysqli_connect($servername, $username,$password,$dbname);
mysqli_select_db($conn,$dbname);
if(isset($_POST['submit'])){
if (isset($_POST['fid']))
{
$fid = $_POST['fid'];
}
$io_id = $_POST['io_id'];
$register_query="INSERT INTO `temp_fir_accept_later`(`fid`, `io_id`) VALUES ('$fid','$io_id')";
mysqli_query($conn,$register_query);
if($register_query){
echo "Data Entered Successfully!";
}
else {
echo "Failed!!!";
}
}
?>