<?
php
include("other.php");
if(isset($_POST["login"])){
$name = $_POST["name"];
$position = $_POST["position"];
$employee = $_POST["employee"];
$sal = $_POST["salary"];
$bonus = $_POST["bonus"];
$result = $sal + $bonus;
$sql = "INSERT INTO
bonus(`name`,`position`,`employee`,`salary`,`bonus`,`total`,`netamount`)
VALUES('$name','$position','$employee','$sal','$bonus','$result','$result')";
mysqli_query($conn,$sql);
mysqli_close($conn);
header("location:profile.php");
exit();
}
?>
<style>
*{
margin: 0;
}
.input_me{
display: flex;
flex-direction: column;
column-gap: 20px;
row-gap: 20px;
}
.input_me input{
width: 200px;
padding: 4px;
border-radius: 5px;
border: solid 1px gray;
}
.input_me label{
width: 100px;
}
#login{
margin-top: 10px;
color: blue;
border: solid 1px blue;
padding: 5px;
width: 95px;
border-radius: 10px;
font-family: fantasy;
cursor: pointer;
}
#close{
margin-top: 10px;
color: red;
border: solid 1px red;
padding: 5px;
width: 95px;
border-radius: 10px;
font-family: fantasy;
cursor: pointer;
}
#add{
margin-bottom: 10px;
cursor: pointer;
margin-top: 10px;
color: green;
border: solid 1px green;
padding: 5px;
width: 95px;
border-radius: 10px;
font-family: fantasy;
cursor: pointer;
}
#table_me{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: rgb(235, 243, 243);
padding: 40px;
width: 200px;
border-radius: 20px;
margin-left: auto;
margin-right: auto;
margin-top: 10%;
border: solid 1px rgb(209, 191, 191);
}
#tableme{
position: absolute;
top: 0;
background-color: rgba(255, 253, 253, 0.932);
width: 100%;
height: 100%;
display: none;
}
</style>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button onclick="addme()" id="add">Add</button>
<br>
<div id="tableme">
<div id="table_me">
<form action="profile.php" method="post">
<div class="input_me">
<label for="name" >Name: <input type="text" name="name" required
></label>
<label for="name" >Position: <input type="text" name ="position"
required></label>
<label for="name" >Employee Number: <input type="text" name
="employee" required></label>
<label for="name" >Salary: <input type="number" name="salary"
required></label>
<label for="name" >Bonus: <input type="number" name="bonus"
required></label>
</div>
<input type="submit" value="login" name="login" id="login"
onclick="login()">
<button id="close" onclick="close()">close</button>
</form>
</div>
</div>
</body>
<script>
function addme(){
document.getElementById("tableme").style.display = "block";
document.getElementById("table_me").style.display = "block";
}
function close(){
document.getElementById("tableme").style.display = "none";
document.getElementById("table_me").style.display = "none";
}
</script>
</html>
<?php
$sql = "SELECT * FROM bonus";
$results = mysqli_query($conn,$sql);
if(mysqli_num_rows($results)>0){
echo "<table border=1>
<tr>
<th>id</th>
<th>Name</th>
<th>Position</th>
<th>Employee</th>
<th>Salary</th>
<th>Bonus</th>
<th>Total amount</th>
<th>Net Amount</th>
<th>Date</th>
</tr>";
while($row = mysqli_fetch_assoc($results)){
echo"<tr>
<td>{$row['id']}</td>
<td>{$row['name']}</td>
<td>{$row['position']}</td>
<td>{$row['employee']}</td>
<td>{$row['salary']}</td>
<td>{$row['bonus']}</td>
<td>{$row['total']}</td>
<td>{$row['netamount']}</td>
<td>{$row['reg_date']}</td>
</tr>";
}
echo"</table>";
}
?>