Notice Undefined index bid in C xampp htdocs userac courier management system-master courier management system-master addstaff php on line 130

0 votes
<?php

require_once('database/config.php');

include('security.php');

include('includes/style.php');

include('branch/includes/header.php');

include('branch/includes/navbar.php');

//session_start();

//if(!isset($_SESSION["branch"])){

//header('Location:login.php');}

if ($_SERVER['REQUEST_METHOD'] == 'POST') {

if (isset($_POST["sname"])) {

$bid = $_SESSION["bid"];

$name = $_POST["sname"];

$email = $_POST["semail"];

$mobile = $_POST["sMob"];

$address = $_POST["sAdd"];

$role = $_POST["role"];

//$branchId = $_SESSION['bid'];

$insert = "INSERT INTO `staff` (`name`,`email`,`mobile`,`address`,`role`,`bid`,`password`) VALUES ('$name','$email', '$mobile','$address', '$role','$bid','123')";

// echo '/n'.$insert;

mysqli_query($conn, $insert);

//header("Location:addstaff.php");

}

}

?>

<div class="container-fluid">

<h1 class="h3 mb-4 text-gray-800">Staff</h1>

<div class="row">

<div class="col-lg-12">

<!-- Add Categories -->

<div class="card shadow mb-4">

<div class="card-header py-3">

<h6 class="m-0 font-weight-bold text-primary">Add New Staff</h6>

</div>

<html>

<head>

<body>

<div class="container-fluid">

<div class="row justify-content-center align-items-center mx-auto" style="width:100%;">

<div class="col-md-12">

<div class="container-fluid" style="margin-top: 10% ;">

<div class="row justify-content-center">

<div class="media-container-column col-lg-8" data-form-type="formoid">

<div data-form-alert="" hidden="">

</div>

<br>

<br>

<form class="mbr-form" action="addstaff.php" method="post">

<div class="row row-sm-offset">

<div class="col-md-7 multi-horizontal" data-for="name">

<div class="form-group ">

<label class="text-dark h5 " for="email-form1-4t"> Name </label><br>

<input type="text" class="form-control" name="sname" data-form-field="Name" required="" id="name-form1-4t">

</div>

</div>

<div class="col-md-7 multi-horizontal" data-for="email">

<div class="form-group">

<label class="text-dark h5" for="email-form1-4t">Email</label>

<input type="email" class="form-control" name="semail" required="">

</div>

</div>

<div class="col-md-7 multi-horizontal" data-for="phone">

<div class="form-group">

<label class="text-dark h5" for="phone-form1-4t">Phone</label>

<input type="number" maxlength="10" class="form-control" name="sMob" data-form-field="Phone" id="phone-form1-4t">

</div>

</div>

</div>

<div class="form-group" data-for="address">

<label class="text-dark h5" for="message-form1-4t">Address</label>

<textarea type="text" class="form-control" name="sAdd" rows="7"></textarea>

</div>

<div class="col-md-7 multi-horizontal" data-for="role">

<div class="form-group">

<label class="text-dark h5" for="role-form1-4t">Role</label>

<select id="role" name="role" class="ml-2 form-control" style="width:100%;height:45px;border-radius:7px;outline:none">

<option value="">Branch Supervisior</option>

<option value="">operation Assistant</option>

<option value="">Area Manager</option>

<option value="">Operation Manager</option>

<option value="">Custom Service User</option>

<option value="">Divisional Manager</option>

<option>Pickup Rider</option>

</select>

</div>

</div>

<span class="input-group-btn">

<button href="" type="submit" class="btn btn-primary btn-form display-4">Register Staff</button>

</span>

</form>

</div>

</div>

</div>

</div>

<div class="col-md-12">

<div class="" style="margin-top:10%; width: 100%;">

<h2> Staff Members</h2>

<table id="datatable" class="table table-striped table-bordered">

<thead>

<tr>

<th>Sr no.</th>

<th>name</th>

<th>Email</th>

<th>Mobile</th>

<th>Address</th>

<th>role</th>

<th>Remove Staff</th>

</tr>

</thead>

<tbody>

<?php

include('database/config.php');

$bid = $_SESSION['bid'];

$mysqli = "select * from staff where bid = '$bid'";

//$mysqli="select * from staff";

$appresult = $conn->query($mysqli);

$i = 1;

while ($res = mysqli_fetch_assoc($appresult)) {

$id = $res['id'];

?>

<tr>

<td><?php echo $i++; ?></td>

<td><?php echo $res['name']; ?></td>

<td><?php echo $res['email']; ?></td>

<td><?php echo $res['mobile']; ?></td>

<td><?php echo $res['address']; ?></td>

<td><?php echo $res['role']; ?></td>

<td>

<form method="post" action="deletestaff.php">

<input type="hidden" value=<?php echo $id; ?> name="sid">

<button type="submit" class="btn btn-danger"><span class="fa fa-trash"></span></button>

</form>

</td>

</tr>

<?php

}

?>

</tbody>

</table>

</div>

</div>

</div>

</div>

</body>

</html>

<?php

include('branch/includes/scripts.php');

/*include('includes/footer.php');*/

?>
Sep 13, 2020 in PHP by saima
• 120 points

edited Sep 14, 2020 by Niroj 2,598 views

1 answer to this question.

0 votes

Hello @saima ,

Before you extract values from $_POST ,$_SESSION, etc  you should check if they exist. You could use the isset function for this and check for each variable weather it extract value or not

answered Sep 14, 2020 by Niroj
• 82,880 points

Related Questions In PHP

0 votes
1 answer

Fatal error: Cannot access empty property in C:\xampp\htdocs\MyTestPages\f.php on line 15

Hello @kartik, You access the property in the ...READ MORE

answered Oct 19, 2020 in PHP by Niroj
• 82,880 points
1,532 views
0 votes
1 answer

Error: Maximum execution time of 60 seconds exceeded in C:\xampp\phpmyadmin\libraries\dbi\mysql.dbi.lib.php on line 140

Hello @kartik, Go to: xampp\phpMyAdmin\libraries\config.default.php Look for : $cfg['ExecTimeLimit'] = 600; You ...READ MORE

answered Sep 1, 2020 in PHP by Niroj
• 82,880 points
13,891 views
0 votes
0 answers
0 votes
1 answer
+1 vote
2 answers

Scp Php files into server using gradle

Tru something like this: plugins { id ...READ MORE

answered Oct 11, 2018 in DevOps & Agile by lina
• 8,220 points
1,207 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
10,978 views
0 votes
1 answer

Failure uploading Image on AmazonS3 with PHP SDK

Try this, I took it out from ...READ MORE

answered May 4, 2018 in AWS by Cloud gunner
• 4,670 points
3,774 views
0 votes
1 answer

Trying to call AWS API via PHP

Try using AWS SDK for PHP, Link ...READ MORE

answered Jun 6, 2018 in AWS by Cloud gunner
• 4,670 points
1,488 views
0 votes
1 answer

Error:Undefined index: barangay in C:\xampp\htdocs\TextBlast\homepage\insert.php on line 22

Hello @ Regina, First checks whether a variable is ...READ MORE

answered Aug 14, 2020 in PHP by Niroj
• 82,880 points
5,415 views
–1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP