Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 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. $intAmount = (($row->monthlyAmount * ($row->intRate/100))/30)*$row->pastDue;
  54. echo 'Amount Owed: ' .$row->monthlyAmount;
  55. echo '<br>';
  56. echo 'Interest rate per month: ' .$row->intRate;
  57. echo '<br>';
  58. echo 'Daily interest: ' .$row->intRate/30;
  59. echo '<br>';
  60. echo 'Days past due: ' .$row->pastDue;
  61. echo '<br>';
  62. echo 'Months past due: ' .$row->monthsOwed;
  63. echo '<br>';
  64. echo 'Interest charge: ' .$intAmount;
  65. echo '<br>';
  66. echo 'Total: ' .($row->monthlyAmount + $intAmount);
  67. echo '<br>';
  68. }
  69.  
  70. mysqli_close($conn);
  71.  
  72. }
  73. else{
  74.  
  75. ?>
  76. <form method = "post" action = "<?php $_PHP_SELF ?>">
  77. <table width = "400" border = "0" cellspacing = "1"
  78. cellpadding = "2">
  79. <tr>
  80. <td width = "100">ID NUMBER</td>
  81. <td><input name = "v_ID" type = "text"
  82. id = "veh_ID"></td>
  83. </tr>
  84. <tr>
  85. <td width = "100"> </td>
  86. <td>
  87. <input name = "check" type = "submit" id = "check"
  88. value = "CHECK">
  89. </td>
  90. </tr>
  91. </table>
  92. </form>
  93.  
  94. <?php
  95. }
  96. ?>
  97.  
  98.  
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement