I have an employee table but when submitted the form data are updated in the employee table of SQL database but the employee data page (header('location:employeedata.php')
) is not displayed. And when I remove sometimes field it work perfectly displaying data on the employee data page. Here below is my PHP code. somebody, please help me
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-state=1"/>
<link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
<script src ="js/jquery-3.4.1.min.js" ></script>
<script src ="js/bootstrap.js" ></script>
<link rel="stylesheet" href="stylemenu.css">
<style type="text/css">
body
{
background-image:url(water.png);
background-size:cover;
}
</style>
</head>
<body>
<?php
session_start();
include("samadonconnection.php");
error_reporting(0);
?>
<div class ="container">
<div class="row">
<div class="col-sm-6"> <h2> Test </h2> </div>
<div class="col-sm-6">
<?php echo "<div style=\"float:right\"> Welcome ". $_SESSION['user']['username']."! </div>"; ?> </div>
</div>
<div class="topnav">
<div class="col-sm-12">
<a href="home.php">HOME</a>
<a href="create_user.php"> + ADD USER</a>
<a class="active" href="employee.php" style="color:blue;">EMPLOYEE</a>
<a href="employeedata.php">EMPLOYEE DATA</a>
<a href="home.php?logout='1'" style="color: red;">LOG OUT</a>
<a href="cont.php">CONTACT US</a>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div id="ui">
<form action="" method="GET" class="form-group">
<div class="row">
<div class ="col-lg-3">
<label> Today Date :</label>
<input type ="date" name ="date" class ="form-control" placeholder=".....">
</div>
<div class ="col-lg-3">
<label> Birth Date :</label>
<input type ="date" name ="birth" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> Mobile :</label>
<input type ="text" name ="mobile" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> Father Name :</label>
<input type ="text" name ="father" class ="form-control" placeholder=".....">
</div>
</div>
<br>
<div class="row">
<div class ="col-lg-3">
<label> First Name :</label>
<input type ="text" name ="fname" class ="form-control" placeholder=".....">
</div>
<div class ="col-lg-3">
<label> Last Name :</label>
<input type ="text" name ="lname" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> Gender :</label>
<select name="gender" class="form-control">
<option> Choose ... </option>
<option> Male </option>
<option> Female </option>
</select>
</div>
<div class ="col-lg-3">
<label> Marital :</label>
<select name="marital" class="form-control">
<option> Choose ... </option>
<option> Married </option>
<option> Unmarried </option>
</select>
</div>
</div>
<br>
<div class="row">
<div class ="col-lg-3">
<label> Email :</label>
<input type ="text" name ="email" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> Qualification :</label>
<input type ="text" name ="qualification" class ="form-control" placeholder=".....">
</div>
<div class ="col-lg-6">
<label> Address :</label>
<input type ="text" name ="address" class ="form-control" placeholder="......">
</div>
</div>
<br>
<div class="row">
<div class ="col-lg-3">
<label> Pin Code :</label>
<input type ="text" name ="pin" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> District :</label>
<input type ="text" name ="district" class ="form-control" placeholder=".....">
</div>
<div class ="col-lg-3">
<label> State :</label>
<input type ="text" name ="state" class ="form-control" placeholder="......">
</div>
<div class ="col-lg-3">
<label> Country :</label>
<input type ="text" name ="country" class ="form-control" placeholder="......">
</div>
</div>
<br>
<div class="row">
</div>
<br>
<input type ="submit" name ="submit" value ="SUBMIT" class ="btn btn-primary btn-block btn-lg">
</form>
<?php
if($_GET['submit'])
{
$da = $_GET['date'];
$bi = $_GET['birth'];
$mo = $_GET['mobile'];
$fa = $_GET['father'];
$fn = $_GET['fname'];
$ln = $_GET['lname'];
$ge = $_GET['gender'];
$ma = $_GET['marital'];
$em = $_GET['email'];
$qu = $_GET['qualification'];
$ad = $_GET['address'];
$pi = $_GET['pin'];
$di = $_GET['district'];
$st = $_GET['state'];
$co = $_GET['country'];
if( $fn!="" && $ln!="")
{
$query = "INSERT INTO employee VALUES
( '$sl','$da','$bi','$mo','$fa','$fn','$ln','$ge','$ma','$em','$qu','$ad' ,'$pi','$di','$st','$co')";
$data = mysqli_query($conn,$query);
if($data)
{
header('location:employeedata.php');
}
}
else
{
echo "All fields are required";
}
}
?>
</div>
</div>
</div>
</div>
</body>
</html>