Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 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 = 'dbvehiculos';
  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: " .
  32. mysqli_error());
  33.  
  34. }
  35.  
  36. $ID = $_POST['v_ID'];
  37.  
  38. $sql = "SELECT * FROM `test` WHERE id=$ID";
  39. //$sql = "INSER INTO test "
  40. //. "(IDVeh, Marca, Modelo, Fecha)"
  41. // . "(monthlyAmount, intRate)"
  42. // . "VALUES ('$ID', '$MAR')";
  43.  
  44. $qry = mysqli_query($conn, $sql) or
  45. die ('Consulta fallida');
  46.  
  47. if(! $qry){
  48. die(mysqli_error());
  49.  
  50. }
  51. $result = mysqli_query($conn, $sql);
  52. while ($row = mysqli_fetch_object($result)) {
  53. echo 'Amount Owed: ' .$row->monthlyAmount;
  54. echo '<br>';
  55. echo 'Interest Rate: ' .$row->intRate;
  56. echo '<br>';
  57. echo 'Daily interest: ' .$row->intRate/30;
  58. echo '<br>';
  59. echo 'Days past due: ' .$row->pastDue;
  60. }
  61.  
  62. mysqli_close($conn);
  63.  
  64. }
  65. else{
  66.  
  67. ?>
  68. <form method = "post" action = "<?php $_PHP_SELF ?>">
  69. <table width = "400" border = "0" cellspacing = "1"
  70. cellpadding = "2">
  71. <tr>
  72. <td width = "100">ID NUMBER</td>
  73. <td><input name = "v_ID" type = "text"
  74. id = "veh_ID"></td>
  75. </tr>
  76. <tr>
  77. <td width = "100"> </td>
  78. <td>
  79. <input name = "check" type = "submit" id = "check"
  80. value = "CHECK">
  81. </td>
  82. </tr>
  83. </table>
  84. </form>
  85.  
  86. <?php
  87. }
  88. ?>
  89.  
  90.  
  91. </body>
  92. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement