Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <?php
  3. if( isset( $_REQUEST['update'] ))
  4. {
  5. $servername = "localhost";
  6. $username = "root";
  7. $password = "";
  8. $dbname = "bc140401259_DB";
  9.  
  10. // Create connection
  11. $conn = mysqli_connect($servername, $username, $password, $dbname);
  12. // Check connection
  13. if (!$conn) {
  14. die("Connection failed: " . mysqli_connect_error());
  15. }
  16. if ( ! empty($_POST['empID'])){
  17. $employeeID = $_POST['empID'];
  18. }else{
  19. $employeeID="";
  20. }
  21. if ( ! empty($_POST['name'])){
  22. $Name = $_POST['name'];
  23. }else{
  24. $Name="";
  25. }
  26. if ( ! empty($_POST['address'])){
  27. $Address = $_POST['address'];
  28. }else{
  29. $Address="";
  30. }
  31. if ( ! empty($_POST['DOB'])){
  32. $Dateofbirth = $_POST['DOB'];
  33. }else{
  34. $Dateofbirth="";
  35. }
  36. if ( ! empty($_POST['salary'])){
  37. $Salary = $_POST['salary'];
  38. }else{
  39. $Salary="";
  40. }
  41. if ( ! empty($_POST['timeIn'])){
  42. $timestamp = $_POST['timeIn'];
  43. }else{
  44. $timestamp="";
  45. }
  46. $sql = "UPDATE Employee SET empID = $employeeID, Name = $Name, Address = $address, Dateofbirth = $DOB, Salary = $salary, Timein = $timeIn";
  47.  
  48. if (mysqli_query($conn, $sql)) {
  49. echo "Record updated successfully";
  50. } else {
  51. echo "Error updating record: " . mysqli_error($conn);
  52. }
  53.  
  54. mysqli_close($conn);
  55. }
  56.  
  57. ?>
  58.  
  59. <html>
  60. <body>
  61.  
  62. <form action="" method="post">
  63. <h2>Add Employee Form</h2>
  64. Employee ID: <input type="text" name="empID" >
  65. <br><br>
  66. Name: <input type="text" name="name" >
  67. <br><br>
  68.  
  69. Address: <input type="text" name="address" >
  70. <br><br>
  71.  
  72. Date of Birth: <input type="text" name="DOB" >
  73. <br><br>
  74.  
  75. Salary: <input type="text" name="salary" >
  76. <br><br>
  77.  
  78. Time In: <input type="text" name="timeIn" >
  79. <br><br>
  80.  
  81. <input type="submit" name="update" value="UPDATE" />
  82.  
  83. </form>
  84. </body>
  85. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement