From ali, 6 Years ago, written in Plain Text.
Embed
  1. <?php
  2. include("includes/db.php");
  3.  
  4.  
  5. if(isset($_REQUEST["gref"]))
  6. {
  7. // echo "<pre>";
  8. // print_r($_REQUEST);
  9. // die;
  10. $date=date('d-m-Y');
  11. $time=date('H:i:s');
  12. $gref=$_REQUEST["gref"];
  13. $gip=$_REQUEST["gip"];
  14. $gport=$_REQUEST["gport"];
  15. $staff=$_REQUEST["staff"];
  16. $mgw=$_REQUEST["mgw"];
  17. $mussd=$_REQUEST["mussd"];
  18. $balance=$_REQUEST["balance"];
  19. $prob=$_REQUEST["problem"];
  20. $action=$_REQUEST["action"];
  21. $comment=$_REQUEST["comment"];
  22. //echo 1;
  23. $header = "<tr>";
  24. $row = "<tr>";
  25. foreach ($_REQUEST as $key => $value) {
  26. $header = $header."<td>".$key."</td>";
  27. $row = $row."<td>".$value."</td>";
  28. }
  29. $header = $header."</tr>";
  30. $row = $row."</tr>";
  31. mysqli_query($con,"insert into minutes(date,time,g_ref,g_ip,g_port,staff,m_gw,m_ussd,balance,problem,action,comment)values('$date','$time','$gref','$gip','$gport','$staff','$mgw','$mussd','$balance','$prob','$action','$comment')");
  32. echo "<table border='2'>".$header.$row."</table>";
  33. die;
  34. }
  35. ?>
  36.  
  37. <!DOCTYPE html>
  38. <html>
  39. <head>
  40. <meta charset="utf-8" />
  41. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  42. <title>Minutes Detail</title>
  43. <meta name="viewport" content="width=device-width, initial-scale=1">
  44. <link rel="stylesheet" type="text/css" media="screen" href="main.css" />
  45. <script src="main.js"></script>
  46. </head>
  47. <body>
  48. <form method="post" id="frm1">
  49. Gateway Ref:
  50. <select name="gref" required>
  51. <option value="">Select Any One</option>
  52. <option value="Ish-01-Qmr">Ish-01-Qmr</option>
  53. </select><br><br>
  54. Gateway IP:<Input type="radio"name="gip"value="192.168.101.101" required>192.168.101.101<Input type="radio"name="gip"value="192.168.101.102" required>192.168.101.102<Input type="radio"name="gip"value="192.168.101.103" required>192.168.101.103
  55. </select><br><br>
  56. Gateway Port:
  57. <?php $filename = 'includes/ports16.txt';
  58. $eachlines = file($filename, FILE_IGNORE_NEW_LINES);//create an array
  59. echo '<select name="gport" id="value" required>';
  60. echo "<option value=''>Select Anyone</option>";
  61. foreach($eachlines as $lines){
  62. echo "<option value='{$lines}'>{$lines}</option>";
  63. }
  64. echo '</select>'; ?><br><br>
  65. Staff:<Input type="text" name="staff" required><br><br>
  66. Minutes On Gateway:<Input type="text" name="mgw"><br><br>
  67. Minutes On USSD:<Input type="text" name="mussd"><br><br>
  68. Balance On USSD:<Input type="text" name="balance" required><br><br>
  69. Problem:
  70. <?php $filename = 'includes/problem.txt';
  71. $eachlines = file($filename, FILE_IGNORE_NEW_LINES);//create an array
  72. echo '<select name="problem" id="value" >';
  73. echo "<option value=''>Select Anyone</option>";
  74. foreach($eachlines as $lines){
  75. echo "<option value='{$lines}'>{$lines}</option>";
  76. }
  77. echo '</select>'; ?><br><br>
  78. Action:
  79. <?php $filename = 'includes/action.txt';
  80. $eachlines = file($filename, FILE_IGNORE_NEW_LINES);//create an array
  81. echo '<select name="action" id="value" >';
  82. echo "<option value=''>Select Anyone</option>";
  83. foreach($eachlines as $lines){
  84. echo "<option value='{$lines}'>{$lines}</option>";
  85. }
  86. echo '</select>'; ?><br><br>
  87. Comments:<Input type="text" name="comment" ><br><br>
  88. <br><br>
  89. <Input type="submit" value="insert" name="submit">
  90. </form>
  91. </body>
  92. <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <!-- load jquery via CDN -->
  93. <script>
  94. $(document).ready(function(){
  95. $('form').submit(function(event) {
  96. event.preventDefault();
  97.  
  98. // get the form data
  99. // there are many ways to get this data using jQuery (you can use the class or id also)
  100. var formData = $(this).serializeArray()
  101. console.log(formData)
  102. // process the form
  103. $.ajax({
  104. type : 'POST', // define the type of HTTP verb we want to use (POST for our form)
  105. // url : '', // the url where we want to POST
  106. data : formData, // our data object
  107. dataType : 'html', // what type of data do we expect back from the server
  108. encode : true
  109. })
  110. // using the done promise callback
  111. .done(function(data) {
  112. // reset the form data
  113. console.log(data)
  114. document.getElementById('frm1').reset();
  115. $('#frm1').hide();
  116. $('body').append(data);
  117. setTimeout(() => {
  118. $('#frm1').show();
  119. $('table').remove();
  120. }, 15000);
  121. // log data to the console so we can see
  122. // alert('done');
  123.  
  124. // here we will handle errors and validation messages
  125. });
  126.  
  127. // stop the form from submitting the normal way and refreshing the page
  128. });
  129.  
  130.  
  131. })
  132. </script>
  133. </html>