0
<?php
    require_once(realpath(dirname(__FILE__) . '/config.php'));
    $db = new Connect;
    $no_of_rides = 0;
    $user = ("SELECT * FROM cab_booking_requests");
    $result = $db->query($user);

    echo '<table>
      <tr>
        <th>id</th>
        <th>User Name</th>
        <th>E mail</th>
        <th>Status</th>
        <th>Update</th>
        <th>check</th>
        <th>id</th>
        <th>Button</th>
      </tr>';

    if($result->rowCount() > 0){
        require_once 'location_master.php';
        while($info = $result->fetch(PDO::FETCH_ASSOC)){
            $bookingid = $info["bookingid"];
            $status = $info["status"];
            $reason = $info["reason"];
            $customer_name = $info["customer_name"];

            echo "<tr><td></td><td>".$status."</td><td>".$reason."</td><td>".$customer_name.'</td><td><div class="body">
          <div class="input-emails">
          <form method="POST" action="location_master.php">
            <select class="combo" id="combobox" name="select" >
            <option value="active">Active</option>
            <option value="deactive">DeActive</option>
              
              
            </select>
          </td><td><input type="checkbox" id="vehicle1" name="check" value="false">
          </td><td><input type="text" name="updat"  value="'.$bookingid.'" disabled>
          </td><td><input type="submit" name="update" value="Update">
          </td></div></tr></form>';
        }

        echo '</table></div>';
    }

This error is really killing me.
I've tried the following, but it doesn't work:

  • if (isset($_POST['update']) && isset($_POST['check']) && isset($_POST['select']) && isset($_POST['updat']))
  • if (isset($_POST['update'], $_POST['check'],$_POST['select'],$_POST['updat'])){

Notice: Undefined index: updat in C:\xampp\htdocs\admin\location_master.php on line 14

<!DOCTYPE html>
    <html lang="en" class="js">
    <?php
        require_once('sidebar.php');
    ?>

    <div>
    <?php
        require_once(realpath(dirname(__FILE__) . '/config.php'));
        require_once('830.php');
        
        if (isset($_POST['update'])) {
            $true = $_POST['check'];
            $satus = $_POST['select'];
            $i = $_POST['updat'];
            echo $satus;
            
            $db = new Connect;
            $user = ("SELECT * FROM cab_booking_requests");
            $result = $db->query($user);
            $info = $result->fetch(PDO::FETCH_ASSOC);
            $hash = $satus;
            $stu = $true;
            
            $upd = $db->prepare("UPDATE cab_booking_requests SET telecall_status =:hash, telecaller_check=:st WHERE bookingid=:ex_user");
            $upd -> execute(array(
                'hash' => $hash,
                'st' => $stu,
                'ex_user' => $i
            ));
            //$db-> query("INSERT INTO cab_booking_requests (telecall_status,telecaller_check) VALUES ('$satus','$true')") or die($mysqli->error);
        }else{
            echo "somehing went wrong";
        }
    ?> 
    </div>

    <?php
        require_once('footer.php');
    ?>
</html>
DarkBee
  • 16,592
  • 6
  • 46
  • 58
Cyper
  • 13
  • 3

2 Answers2

0

updat field is disabled is your submission, hence it is not submitted and therefore your submission script could not receive it so it says undefined index. If you want that field to be disabled so that user cant change it, make it readonly not disabled.

0

Write print_r($_POST) in the code and check all the post data that is coming from the client side i.e browser check weather index updat is available or not

Reason if index is not available

  1. The field is disabled.
  2. Your are using wrong selector in JavaScript for fetching variable.
  3. Missing "." in case of class name or "#" in case of ID (In Case of jQuery).
  4. The field display property is none.
  5. If the value is coming from radio button and none of the radio is checked.

Please provide the client side scripting also if the answer won't provide any solution

  • 2
    Javascript has nothing to due with OP's answer. Also hidding an input doesn't prevent the input's value being passed to the backed - [demo](https://www.darkbee.be/stack/hidden.php) – DarkBee Mar 31 '21 at 09:14
  • yes the data is not coming – Cyper Mar 31 '21 at 09:20
  • index updat is not available ///Array ( [select] => deactive [check] => false [update] => Update ) – Cyper Mar 31 '21 at 10:06