Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- if( isset( $_REQUEST['update'] ))
- {
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "bc140401259_DB";
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- if ( ! empty($_POST['empID'])){
- $employeeID = $_POST['empID'];
- }else{
- $employeeID="";
- }
- if ( ! empty($_POST['name'])){
- $Name = $_POST['name'];
- }else{
- $Name="";
- }
- if ( ! empty($_POST['address'])){
- $Address = $_POST['address'];
- }else{
- $Address="";
- }
- if ( ! empty($_POST['DOB'])){
- $Dateofbirth = $_POST['DOB'];
- }else{
- $Dateofbirth="";
- }
- if ( ! empty($_POST['salary'])){
- $Salary = $_POST['salary'];
- }else{
- $Salary="";
- }
- if ( ! empty($_POST['timeIn'])){
- $timestamp = $_POST['timeIn'];
- }else{
- $timestamp="";
- }
- $sql = "UPDATE Employee SET empID = $employeeID, Name = $Name, Address = $address, Dateofbirth = $DOB, Salary = $salary, Timein = $timeIn";
- if (mysqli_query($conn, $sql)) {
- echo "Record updated successfully";
- } else {
- echo "Error updating record: " . mysqli_error($conn);
- }
- mysqli_close($conn);
- }
- ?>
- <html>
- <body>
- <form action="" method="post">
- <h2>Add Employee Form</h2>
- Employee ID: <input type="text" name="empID" >
- <br><br>
- Name: <input type="text" name="name" >
- <br><br>
- Address: <input type="text" name="address" >
- <br><br>
- Date of Birth: <input type="text" name="DOB" >
- <br><br>
- Salary: <input type="text" name="salary" >
- <br><br>
- Time In: <input type="text" name="timeIn" >
- <br><br>
- <input type="submit" name="update" value="UPDATE" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement