Advertisement
Guest User

Untitled

a guest
Oct 29th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. <?php
  2. include('../includes/session.php');
  3. ?>
  4. <html>
  5. <?php require('../includes/header.php'); ?>
  6. <body>
  7. <?php require('../includes/navbar.php'); ?>
  8. <div class="container">
  9. <h2>New Employee</h2>
  10. <!-- Trigger the modal with a button -->
  11. <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">New Employee</button>
  12. <!-- Modal -->
  13. <div class="modal fade" id="myModal" role="dialog">
  14. <div class="modal-dialog">
  15. <!-- Modal content-->
  16. <div class="modal-content">
  17. <div class="modal-header">
  18. <button type="button" class="close" data-dismiss="modal">&times;</button>
  19. <h4 class="modal-title">New Employee</h4>
  20. </div>
  21. <div class="modal-body">
  22. <form class="form-horizontal" action="../functions/addemployee.php" method="post">
  23. <fieldset>
  24. <!-- Text input-->
  25. <div class="form-group">
  26. <label class="col-md-4 control-label" for="firstname">First Name</label>
  27. <div class="col-md-4">
  28. <input id="firstname" name="firstname" type="text" placeholder="First Name" class="form-control input-md" required="">
  29. </div>
  30. </div>
  31. <!-- Text input-->
  32. <div class="form-group">
  33. <label class="col-md-4 control-label" for="lastname">Last Name</label>
  34. <div class="col-md-4">
  35. <input id="lastname" name="lastname" type="text" placeholder="Last Name" class="form-control input-md">
  36. </div>
  37. </div>
  38. <!-- Text input-->
  39. <div class="form-group">
  40. <label class="col-md-4 control-label" for="username">Username</label>
  41. <div class="col-md-4">
  42. <input id="username" name="username" type="text" placeholder="Username" class="form-control input-md">
  43. </div>
  44. </div>
  45. <!-- Password input-->
  46. <div class="form-group">
  47. <label class="col-md-4 control-label" for="password">Password</label>
  48. <div class="col-md-4">
  49. <input id="password" name="password" type="password" placeholder="Password" class="form-control input-md">
  50. </div>
  51. </div>
  52. <!-- Button -->
  53. <div class="form-group">
  54. <label class="col-md-4 control-label" for="submit"></label>
  55. <div class="col-md-4">
  56. <button id="submit" name="submit" class="btn btn-primary">Add Employee</button>
  57. </div>
  58. </div>
  59. </fieldset>
  60. </form>
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. </body>
  67. </html>
  68.  
  69. <?php
  70.  
  71. include("../includes/config.php");
  72.  
  73.  
  74. $firstname = mysqli_real_escape_string($db,$_POST['firstname']);
  75. $lastname = mysqli_real_escape_string($db,$_POST['lastname']);
  76. $username = mysqli_real_escape_string($db,$_POST['username']);
  77. $password = mysqli_real_escape_string($db,$_POST['password']);
  78.  
  79.  
  80. $sql = "INSERT INTO employees (id, firtname, lastname, username, password) VALUES ('', '$firstname', '$lastname', '$username', '$password')";
  81.  
  82. if (!mysql_query($db,$sql)) {
  83. die('Error: ' . mysql_error());
  84. }
  85.  
  86. ?>
  87.  
  88. <?php
  89. define('DB_SERVER', 'localhost');
  90. define('DB_USERNAME', 'root');
  91. define('DB_PASSWORD', '');
  92. define('DB_DATABASE', 'breitinger');
  93. $db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement