0

I want to insert fid and io_id values into a table named temp_fir_accept_later and here io_id is a new field so it directly gets entered to database table successfully. But the fid value is grabbed from another previously made table named fir, so when I submit both values, fid shows Error as:

"Notice: Undefined variable: fid in C:\wamp\www\myProjectMJb\dashboard\admin_dashboard_menus\fir_accept_later.php on line 17".

So how can I fix that problem? Below I have shown my code:

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!!!";
}
}
?>
ifconfig
  • 6,242
  • 7
  • 41
  • 65
  • Possible duplicate of ["Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset" using PHP](https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined) – Chris White May 07 '19 at 20:15
  • Well formatted code in questions goes a LONG way towards making them easier to read and understand. Proper grammar helps too. – ifconfig May 08 '19 at 02:51

0 Answers0