Advertisement
Guest User

Untitled

a guest
Mar 9th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <!--
  3. To change this license header, choose License Headers in Project Properties.
  4. To change this template file, choose Tools | Templates
  5. and open the template in the editor.
  6. -->
  7. <html>
  8. <head>
  9. <meta charset="UTF-8">
  10. <title></title>
  11. </head>
  12. <body>
  13. <?php
  14.  
  15. if (isset($_POST['check'])) {
  16. $dbhost = '127.0.0.1';
  17. $dbuser = 'root';
  18. $dbpass = '';
  19. $db = 'lala';
  20.  
  21. $conn = mysqli_connect($dbhost, $dbuser, $dbpass);
  22.  
  23. if (!$conn) {
  24. die("Fallo en conexión: " . mysqli_error());
  25.  
  26. }
  27.  
  28. $db_select = mysqli_select_db($conn, $db);
  29.  
  30. if (!$db_select) {
  31. die("Fallo en conexión a base de datos: " . mysqli_error());
  32.  
  33. }
  34.  
  35. $name = $_POST['p_Name'];
  36. $type = $_POST['p_Type'];
  37. $telephone = $_POST['p_Telephone'];
  38. $address = $_POST['p_Address'];
  39. $date = $_POST['p_Date'];
  40.  
  41. $sql = "INSERT INTO `employee`(`name`, `type`, `telephone`, `address`, `employmentDate`) VALUES ('$name','$type','$telephone','$address',$date)";
  42.  
  43. $qry = mysqli_query($conn, $sql) or die('Consulta fallida');
  44.  
  45. if (!$qry) {
  46. die(mysqli_error());
  47.  
  48. }
  49. $result = mysqli_query($conn, $sql);
  50. echo 'done';
  51. mysqli_close($conn);
  52. } else {
  53.  
  54. ?>
  55. <form method = "post" action = "<?php $_PHP_SELF; ?>">
  56. <table width = "400" border = "0" cellspacing = "1" cellpadding = "2">
  57. <tr>
  58. <td width = "100">NAME</td>
  59. <td><input name = "p_Name" type = "text" id = "post_Name"></td>
  60. </tr>
  61. <tr>
  62. <td width = "100">TYPE</td>
  63. <td><input name = "p_Type" type = "text" id = "post_Type"></td>
  64. </tr>
  65. <tr>
  66. <td width = "100">Telephone</td>
  67. <td><input name = "p_Telephone" type = "text" id = "post_Telephone"></td>
  68. </tr>
  69. <tr>
  70. <td width = "100">Address</td>
  71. <td><input name = "p_Address" type = "text" id = "post_Address"></td>
  72. </tr>
  73. <tr>
  74. <td width = "100">Date</td>
  75. <td><input name = "p_Date" type = "text" value = "2018-03-09" id = "post_Date"></td>
  76. </tr>
  77. <tr>
  78. <td width = "100"> </td>
  79. <td> <input name = "check" type = "submit" id = "check" value = "Insert">
  80. </td>
  81. </tr>
  82. </table>
  83. </form>
  84.  
  85. <?php
  86. }
  87. ?>
  88. </body>
  89. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement